jpegoptim is the utility of choice for optimizing JPEG files. By default, it uses standard JPEG encoding library on your system. However, there is a relatively new player in town of JPEG encoders – MozJPEG.
MozJPEG encoder provides improvements compared to standard library by reducing the size of JPEG files further. So if you couple
jpegoptim with MozJPEG, – you get furthermore smaller files without loosing any quality!
Install jpegoptim with MozJPEG support
Our repository has
jpegoptim compiled with MozJPEG linked in statically. So all you need to do is add up our repository and install the package:
yum -y install https://extras.getpagespeed.com/release-el7-latest.rpm yum -y install jpegoptim
jpegoptim as you would normally, by simply running
jpegoptim /path/to/file, or while providing whatever switches required for your use cases. The optimized files will be just more lightweight, compared to standard libjpeg-turbo, at no cost of quality!
Example lossless optimization comparison
Using jpegoptim with standard JPEG encoder
beautiful-girl-stands-park_8353-5085.jpg 626×417 24bit N JFIF [OK] 69291 –> 67808 bytes (2.14%), optimized.
Using jpegoptim with MozJPEG
beautiful-girl-stands-park_8353-5085.jpg 626×417 24bit N JFIF [OK] 69291 –> 65898 bytes (4.90%), optimized.
Most of the files we tried provided similar extra 2-3% improvements. So no excuse not to leverage the power of MozJPEG!
Also published on Medium.