An image batch processing tool based on fast-glob and sharp.js, mainly used for image compression and format conversion
npm install @gap-l/batch-compress
npm i @gap-l/batch-compress -D
`
Usage
` ts
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,
})
``