ariya.io About Talks Articles

Squeezing JPEG Images with Guetzli

3 min read

Guetzli, a new JPEG encoder from Google, is a promising solution to reduce the size of JPEG images without causing any perceptible degradation in quality.

As an image format, JPEG is extremely popular, particularly for photos. A JPEG encoder is responsible to take an input image and produce a corresponding a JPEG file, ideally of course with the size much much smaller than the original. A well-known flavor of a modernized JPEG encoder is MozJPEG, developed by Mozilla. Check my previous my blog post Using MozJPEG via Docker if you want to know more about MozJPEG.

As of lately, there is a new kid on the block, Guetzli from Google. Trying out Guetzli is easy, since the project page prepares prebuilt binaries for Linux, macOS, and Windows. Of course, if you fancy building it from source, that is also a possibility. Once the executable is available, running it is even easier:

guetzli original.jpg optimized.jpg

My test on running Guetzli on a 10-megapixel photo (birds-of-paradise) yields the following result

Chart

The original image, almost 3 MB in size, is what Canon EOS 400D produced. Reencoding it with MozJPEG with quality of 95 brought it to around 1.3 MB. Finally, running Guetzli on this file saved another 326 KB, reducing the file size to barely 1 MB. When I compare the original photo with what Guetzli optimizes, frankly I can not notice any difference. For the practical purpose of sharing the photo in social media or projecting it to a big TV for the whole family to enjoy, the output of Guetzli is just as good as the original.

The trick employed by Guetzli is to search for a particular JPEG quantization that optimizes its pyschovisual model. This explains why Guetzli’s tagline is Perceptual JPEG Encoder. Practically speaking, the model is not new as it has been unveild by the Butteraugli project:

Butteraugli is a project that estimates the psychovisual similarity of two images. It gives a score for the images that is reliable in the domain of barely noticeable differences.

The drawback of this technique is that the search is computationally expensive. In the example I have given above, for that 10-megapixel photo, Guetzli ran for 28 minutes before it finished. On top of that, it was also very hungry, consuming 1 GB of memory during the optimization.

However, for a much smaller image, the optimization is more reasonable. When I ran Guetzli on this simple banner, the width is just 600 pixels, the optimization was completed in just a few seconds, reducing the file size from 27,950 bytes to just 20,836 bytes. For such a simple step, saving 7 KB for everyone who needs to download the image is totally worth the effort.

Let the Guetzlification begin!

Related posts:

♡ this article? Explore more articles and follow me Twitter.

Share this on Twitter Facebook