pic-shrink is an easy-to-use CLI tool for compressing images in JPG, PNG, and WEBP.
npm install -g pic-shrink
To compress a single image file, you can use the following command:
pic-shrink <image-file-path>
To compress multiple image files run the following command:
pic-shrink -i <images-path> -o <output-path> -c <compression-level>
Replace <images-path>
with the path to the directory containing the images you want to compress.
Replace <output-path>
with the optional path to the directory where you want to store the compressed images. If not provided, the compressed images will be stored in the same directory as the original images.
Replace <compression-level>
with an optional value between 1 and 10 to specify the compression level for the images. Lower values result in higher compression and lower image quality, while higher values result in lower compression and higher image quality. If not provided, the default compression level of 7 will be used.
Compress a single image file
pic-shrink image.jpg
Compress a single image file with a custom compression level
pic-shrink image.jpg -c 4
Compress images located in the "images" directory and store the compressed images in the same directory:
pic-shrink -i images
Compress images located in the "images" directory and store the compressed images in the "output" directory. If the "output" directory does not exist it will be created automatically:
pic-shrink -i images -o output
Compress images located in the "images" directory with a custom compression level:
pic-shrink -i images -c 5
sharp
package to perform image compression.Please feel free to create issues for any bugs or unexpected behaviour you come across while using this tool.