The ability to shrink JPEG images is important to developers of all disciplines, but reducing file size without degradation can be tricky. Google just open-sourced a tool that shrinks JPEG file size by up to 35 percent, and may even improve image quality as a result.
The oddly named ‘Guetzli’ (Swiss-German for ‘cookie,’ of all things to name a web tool) was created so web developers could “create webpages that can load faster and use even less data.” It works with existing browsers, image processing apps and JPEG standards. Google likens it to Zopfli, its algorithm for reducing PNG file sizes.
Noting JPEG visual quality has three key points, Guetzli focusses on ‘quantization,’ which is the piece that causes degradation in file size reduction. From Google:
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.
Need an English version of that? In the quantization stage of file size reduction, colors in an image are often morphed from visually appealing gradients to ugly blocks. This is done because pixels are data points, and blocks of data are more organized and easier to compress. Guetzli doesn’t do this. Instead, the algorithm tries to figure out which pieces of data make an image appealing to the human eye and prioritizes those.
Because of all this under-the-hood magic, Guetzli is admittedly slower than the more widely-used libjpeg method for reducing image file size. Google says humans prefer Guetzli to libjpeg when comparing compressed images side by side, “even when the libjpeg files were the same size or even slightly larger.” To that end, it considers slower compression for better image quality a fair concession.
Guetzli sounds the part, and Google says your images will look the part, so it might just be worth checking out. It’s also open-source, so expect tool makers to start fiddling with it to make their own image compression apps. That tweaking may boost Guetzli’s abilities even further.