A batch image compressor cli based on [tinify](https://www.npmjs.com/package/tinify) and [sharp](https://www.npmjs.com/package/sharp), it will compress images and **replace them** by default.
npm install image-compressor-clibash
npm install -g image-compressor-cli
`
Usage
$3
go to tinify and get your api keyExecute with follow command to set your api key,
`bash
image-compressor-cli config -k
`
and you can useimage-compressor-cli config --show to view your current api key.
Then you can use the following commands to compress images
Currently, the images compressed by Tinify (jpg, jpeg, png, webp) are not supported custom quality, so you can only use the default quality.$3
`bash
image-compressor-cli --quality 80
`$3
`bash
image-compressor-cli --colors 128
`$3
`bash
image-compressor-cli --output-dir ./output
`$3
`bash
image-compressor-cli
`Options:
`
-V, --version output the version number
-q, --quality Set Sharp static image quality (default: 80)
-c, --colors Set gif image maximum number of palette entries, including transparency, between 2 and
256 (default: 128)
-o, --output-dir Specify a custom output directory
-h, --help display help for commandCommands:
config [options] API key configuration management
help [command] display help for command
``| supported extensions | notes |
|:---------------------|:-----------------------------------:|
| jpg | lossy compression |
| jpeg | lossy compression |
| png | lossless compression |
| tiff | lossless compression |
| webp | lossy compression |
| gif | lossy compression |
p.s.
1. Please TEST before large scale compression
2. WebP is generally smaller and higher quality than JPEG and PNG formats, so pay attention to the selection of compression parameters when compressing to prevent image distortion caused by over-compression.