What Is Guetzli and Why Does It Use So Much CPU?
Google’s Guetzli is an open-source JPEG encoder designed to produce high-quality images with significantly smaller file sizes than traditional encoders while maintaining full compatibility with existing browsers. This article explores how Guetzli achieves a 20–30% reduction in file size through psychovisual modeling, and explains why its complex, iterative optimization algorithm requires vastly more CPU time and memory than standard JPEG compression tools.
What Is Guetzli?
Guetzli is a JPEG encoder released by Google in 2017. Unlike newer image formats such as WebP, AVIF, or JPEG XL, Guetzli does not introduce a new file format. Instead, it generates completely standard, backward-compatible JPEG files. Any browser, image viewer, or operating system that can decode a normal JPEG can read a Guetzli-compressed image without updates or plugins.
Standard JPEG compression often produces noticeable artifacts, such as ringing around sharp edges or blockiness in complex textures, when file sizes are heavily reduced. Guetzli bridges the gap between high visual fidelity and low file size by optimizing the standard JPEG compression steps to better match human visual perception.
Perceptual Encoding with Butteraugli
The core of Guetzli’s visual efficiency lies in Butteraugli, Google’s perceptual image metric. Traditional encoders rely on simplified mathematical formulas—like Mean Squared Error (MSE) or Peak Signal-to-Noise Ratio (PSNR)—to determine how much an image has degraded during compression. However, these metrics do not accurately reflect how human eyes perceive differences.
Butteraugli models the human visual system:
- It simulates the precise sensitivities of human retinal cone cells (especially the blue-yellow and green-red color opponent processes).
- It measures spatial frequency sensitivity, recognizing that the human eye is less sensitive to fine variations in high-frequency patterns and low-light areas.
- It identifies where JPEG compression artifacts will be invisible to the human eye, allowing the encoder to discard unnoticeable data.
Why Guetzli Demands Significant CPU Time
Guetzli’s CPU-intensive nature is directly tied to how it applies the
Butteraugli metric. While standard encoders like libjpeg
compress an image in a single, linear pass, Guetzli treats compression
as a multi-variable optimization problem that must be solved through
continuous iteration.
1. The Iterative Search Loop
Standard encoders apply fixed or semi-custom quantization tables to Discrete Cosine Transform (DCT) values and output the file immediately. Guetzli, by contrast, enters an extensive trial-and-error loop:
- It applies a set of candidate quantization values and coefficient adjustments.
- It fully decompresses the resulting candidate image back into memory.
- It runs the computationally heavy Butteraugli algorithm to measure perceived visual difference against the original image.
- It adjusts the parameters and repeats the entire cycle.
This process can repeat dozens or hundreds of times across various blocks of the image until the algorithm converges on the smallest possible file size that stays below a strict perceptual error threshold.
2. Butteraugli’s Computational Complexity
The Butteraugli metric itself requires heavy mathematical processing. It performs non-linear transformations across color spaces, spatial filtering, and complex psychovisual evaluations on every single iteration. Running this model repeatedly across high-resolution imagery forces CPU cores to sustain high utilization for extended periods.
3. Memory Requirements
Guetzli does not just use heavy CPU; it also requires substantial RAM. Because it must hold multiple uncompressed variants of the image in memory simultaneously to compute psychovisual differences, compressing a single multi-megapixel photo can consume several hundred megabytes to gigabytes of memory.
When to Use Guetzli
Because encoding can take anywhere from several seconds to several minutes per image, Guetzli is unsuited for real-time applications, user uploads, or dynamic image pipelines.
Guetzli is designed specifically for static web assets. When an image will be served millions of times to web users, spending minutes of CPU power up front is an effective trade-off, as the resulting 20–30% bandwidth savings permanently reduce storage, network costs, and page load times.