Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@gap-l/batch-compress

Gap-L218MIT1.1.0TypeScript support: included

An image batch processing tool based on fast-glob and sharp.js, mainly used for image compression and format conversion

image process, image compress, image format convert

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,
})