Update: Two of the slides in the bees.png file were swapped relative to what the text said was being compared. This error has been corrected.
Google has announced a new and improved JPEG implementation that it claims can shrink file sizes by as much as 35% with better image quality than you’d see in an equivalent standard JPEG file. That kind of improvement would be significantly useful, if true — repeated studies have shown a distinct correlation between website load times and how likely a user is to remain engaged. Speed matters on the Internet, and Google has been focused on improving web performance for years.
A joint blog post by Robert Obryk and Jyrki Alakuijala describes the new compression method as similar to Google’s Zopfli, which can be used to create smaller PNG images and compress files. Here’s how they describe the new Guetzli (it means “cookie” in Swiss German).
The visual quality of JPEG images is directly correlated to its multi-stage compression process: color space transform, discrete cosine transform, and quantization. Guetzli specifically targets the quantization stage in which the more visual quality loss is introduced, the smaller the resulting file. Guetzli strikes a balance between minimal loss and file size by employing 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 than what is achievable by simpler color transforms and the discrete cosine transform. However, while Guetzli creates smaller image file sizes, the tradeoff is that these search algorithms take significantly longer to create compressed images than currently available methods.
Google included some of its own image assets to demonstrate the quality difference between Guetzli, a standard PNG, and a conventional JPEG.
The Guetzli image is clearly better than the conventional JPEG file created with the libjpeg library, but we wanted to create some comparisons of our own. Luckily there’s a Guetzli binary image available to download. It even includes a sample file if you want to compare image quality yourself. We were curious to see how the program’s output would stand up in testing, so we’ve done some testing of our own. All of our image editing and standard JPEG creation was done in version 4.0.13 of Paint.net.
The slideshows below contains multiple types of images, so we’re going to walk through them in advance. The first three slides consist of the bees.png file Google provided in Github, followed by the same file saved as a normal JPEG, followed by Google’s Guetzli implementation. The easiest way to see the differences between them is to open each slide in a new window, enlarge the image to 500-600%, and then tab between them. Check the flower in the lower right-hand-corner of the image and you’ll see that Guetzli does a better job of maintaining proper color compared to a regular JPEG file.
If you zoom in on the top left bee (800% ought to do it) you’ll see a similar effect. Guetzli and the original PNG clearly show the flower’s anther — that’s the brown bit at the tip that actually contains the pollen. In the standard JPEG file, that information has been lost. The next two slides are differential comparisons. First we compare the PNG file against the normal JPEG encode, followed by a comparison of the PNG file against Guetzli. The more spots there are in the image, the greater the difference between the original PNG and the JPEG.
So far, so good. The Guetzli compression clearly loses less data. But how about something a little more challenging? The next slideshow is an extreme close-up (500%) on a 4K PNG image capture from Skyrim’s special edition. You’ll want to open each image in a separate window and flip back and forth to compare them. Look at the edges of the foliage on the left-hand side to see the variations between the three files. The original image is shown below.
We perform the same differential comparison as we did in the first slideshow, but this time the results are rather different.
In this case, which image looks best is arguably a matter of personal preference, and it depends on where you look. Generally speaking, Guetzli does a better job of replicating color, but look at the diagonal rock in the lower left hand corner. The standard JPEG algorithm handles that edge more closely to the PNG file, while Guetzli blurs it. Guetzli seems to struggle with accuracy in a few areas in our 4K image, producing an end result that’s actually more inaccurate than the standard JPEG. This isn’t automatically a problem since the application is still in development, but it does point to a need for further improvement.