Google’s Guetzli Promises Smaller, Better Looking JPEGs
Earlier this month, Google announced a new JPEG encoding algorithm that promises high quality images with a savings of up to 35% in file size. Guetzli (Swiss German for cookie) is Google’s new, open source method of encoding JPEGs that “strikes a balance between minimal loss and file size…”(source). Meaning, there tends to be fewer artifacts, thus creating an image that is both smaller and looks better.
One component of this new encoding method is that it specifically employs
“…a search algorithm that tries to overcome the difference between the psychovisual modeling of JPEG’s format, and Guetzli’s psychovisual model, which approximates color perception and visual masking in a more thorough and detailed way…”(source).
Which means that it’s intentionally encoding JPEGs based in part of how it will be perceived by a human observer.
Google references experiments where human raters consistently favor the Guetzli images over libjpeg images in support of their claims.
So smaller file sizes and better looking images. That certain sounds good, right? So how do you employ this new algorithm in creating JPEGs? That’s what I was thinking when I first heard the announcement, and the following was my initial experience with Guetzli.
Testing it out
First, you can download Guetzli via their GitHub page. There you’ll also find installation and usage instructions. After installation, you can use it via the command line like this:
$ guetzli SOURCE_FILE.png OUTPUT_FILE.jpg
After I had downloaded and installed it, I used this command to compress a sample image they had also provided. I also ran the same image through Fireworks at 80 quality. To my surprise, the Guetzli image was actually larger. What happened? Well, after some digging, I found that by default, Guetzli uses an image quality of 95, which is way higher than the 80 I was using with the other image.
After looking at the docs, I saw that you can set the quality of the image via the
$ guetzli --quality NN SOURCE_FILE.png OUTPUT_FILE.jpg
So I tried running it again at 80 so it would be comparable to my other compressed file.
$ guetzli --quality 80 SOURCE_FILE.png OUTPUT_FILE.jpg
But I ran into little problem: Guetzli is specifically designed for higher quality photos, and by default doesn’t use a quality setting less than 84. Here how the CLI responded after trying 80:
Guetzli should be called with quality >= 84, otherwise the output will have noticeable artifacts. If you want to proceed anyway, please edit the source code. Guetzli processing failed
So, I ran it again at 85, and it worked. The file was indeed smaller than my original try. I also recompressed the original file using Fireworks at 85, so I could compare the images at the same quality levels. Below were the results:
Guetzli is still new, but here are my initial reactions.
- First, the best thing is it’s producing a JPEG. It isn’t a new format that needs time to be supported. Guetzli is simply a more efficient way of encoding JPEGs. And this is huge. It can be used immediately, and we can all reap the performance gains that comes from the file size savings.
- Second, it looks good. This is subjective, but Guetzli tends to looks better when comparing images of either comparable size or ‘quality’
- Finally, tooling is already on the way. Soon after Guetzli was announce, ImageOptim also announced support in their popular software for image optimization.
- It’s resource intensive. Depending on the quality level and the size of the original image, it can take a long time to encode a single image. This may not be a big deal, depending on your situation. But it is something to keep in mind, especially if you’re looking to integrate it into your workflow, or want to use it dynamically on the fly.
Overall, Guetzli appears to be a great next step in continuing to optimize images for the web. JPEGs are already universally supported, so the new encoding can be used immediately. Couple the file size savings with better looking images, and you have a recipe for success. There may be discrepancies about whether they truly look better. But the performance gains from the smaller file sizes is a significant win in its own right.