@gap-l/batch-compress
v1.1.0
Published
An image batch processing tool based on fast-glob and sharp.js, mainly used for image compression and format conversion
Downloads
290
Maintainers
Readme
batch-compress
Install
npm i @gap-l/batch-compress -D
Usage
const { batchCompress } = require('@gap-l/batch-compress');
batchCompress({
// 需要压缩的图片路径
inputArr: ['./images/**/*.png'],
format: 'png', // 'jpeg' | 'jp2' | 'png' | 'webp' | 'gif' | 'avif' | 'heif' | 'tiff'
// 压缩后的图片输出路径
outputPath: `./outputImg`,
outputConfig: {
// docs: https://sharp.pixelplumbing.com/api-output#webp
quality: 60,
},
maintainRelativePath: true,
})