guetzli
Encode JPEG images for smaller file size
TLDR
Compress a JPEG image
Create a compressed JPEG from a PNG
Compress a JPEG with the desired visual quality (84-100)
SYNOPSIS
guetzli [options] input_file output_file
PARAMETERS
-quality N
Sets the output JPEG quality level. Accepted values range from 84 to 100. The default is 95. Note that Guetzli's quality scale is not directly comparable to other JPEG encoders (e.g., libjpeg).
-verbose
Prints a detailed log of the encoding progress to the console.
-print_psnr
Prints the Peak Signal-to-Noise Ratio (PSNR) and Butteraugli distance values for the processed image.
-memlimit N
Sets the maximum memory usage limit in GiB. The default is 6GiB. This parameter is crucial for processing large images and can be increased if memory issues occur.
-num_threads N
Specifies the number of threads to use for processing. The default is 1. While it can speed up batch processing of multiple images, a single image is still processed on a single thread.
-depth N
Controls the optimization iteration depth, impacting compression efficiency and processing time. Higher values (up to 15) result in more thorough optimization (slower, better compression). The default is 10.
DESCRIPTION
Guetzli is a JPEG encoder developed by Google, specifically designed to create high-quality JPEG images with significantly smaller file sizes. Its core innovation lies in the use of a sophisticated psycho-visual model called Butteraugli, which attempts to identify and reduce visual artifacts that are less noticeable to the human eye. This allows Guetzli to achieve superior compression at a given perceived visual quality compared to traditional JPEG encoders.
While it excels at producing smaller files that maintain visual fidelity, Guetzli is known for being computationally intensive. It requires more processing time and memory than other encoders, making it less suitable for real-time applications but ideal for optimizing static web assets where perceived quality and file size are critical factors.
CAVEATS
Slow Processing: Guetzli is notoriously slow, often taking minutes or even hours for a single high-resolution image.
High Memory Usage: It can consume significant amounts of RAM, especially for very large images. Ensure sufficient memory or adjust the -memlimit.
Quality Scale: The -quality parameter (84-100) is specific to Guetzli and does not directly map to quality settings in other JPEG encoders. Using values below 84 is generally not recommended due to visible artifacts.
Not for All Images: While excellent for photographic content, its benefits may be less pronounced or even counterproductive for images with sharp lines, text, or graphic elements, where its artifacts might be more apparent.
WORKFLOW RECOMMENDATION
Given its high computational cost, Guetzli is best utilized as a final optimization step for critical static web assets, such as hero images or high-traffic visuals. It is typically employed in an offline, batch processing workflow rather than in real-time image serving pipelines.
HISTORY
Guetzli was developed by Google and publicly announced in March 2017. Its primary motivation was to create a new JPEG encoder that could produce visually indistinguishable images at smaller file sizes than existing methods. This was achieved by integrating Google's advanced Butteraugli perceptual metric into the encoding process. The name "Guetzli" is Swiss German for "cookie," a nod to its origin and purpose in web optimization.