Batch optimize and compress JPEG or PNG images with command line tools to reduce the image file size on website.

After all, storage and bandwidth usage in cloud services are billable items … πŸ’ΈοΈ

Smaller file sizes mean less resource usage and faster page loads.

jpegoptim

jpegoptim - utility to optimize/compress JPEG files. Provides lossless optimization (based on optimizing the Huffman tables) and “lossy” optimization based on setting maximum quality factor.

Usage: suits me

$ mkdir jpegoptim_ed
$ jpegoptim -d jpegoptim_ed -m 90 -pst *.jpg

OptiPNG

OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information. This program also converts external formats (BMP, GIF, PNM and TIFF) to optimized PNG, and performs PNG integrity checks and corrections.

Usage: suits me

$ optipng -dir optipng_ed -preserve -strip all *.png

References: