pngquant
Lossy PNG compression via color quantization
TLDR
Compress PNG with quality range
SYNOPSIS
pngquant [--quality min-max] [--speed N] [--output file] [--ext suffix] [colors] files
DESCRIPTION
pngquant compresses PNG images by reducing the number of colors using lossy quantization. It converts 24/32-bit PNG to 8-bit palette PNG, dramatically reducing file size while maintaining visual quality.
The algorithm uses median-cut quantization with dithering to hide color reduction artifacts. Quality settings control how aggressively colors are reduced - higher quality preserves more detail but produces larger files.
Quality range (e.g., 65-80) sets minimum acceptable quality. If the minimum cannot be achieved, pngquant exits without writing (exit code 99). This prevents unacceptably degraded images.
Speed setting trades processing time for output quality. Slower speeds find better color palettes. For automated pipelines, moderate speeds (3-4) offer good balance.
The tool excels at compressing graphics, icons, and images with limited colors. Photographs may show more visible quality loss due to the 256-color limit.
PARAMETERS
--quality MIN-MAX
Quality range (0-100). Skip if quality below MIN.-o, --output FILE
Output file name.--ext SUFFIX
Set output filename suffix (default: -fs8.png).-f, --force
Overwrite existing files.-s N, --speed N
Speed/quality tradeoff (1=slowest, 11=fastest).--skip-if-larger
Don't write if output larger than input.--strip
Remove metadata.--posterize BITS
Reduce precision of color channels.--nofs
Disable Floyd-Steinberg dithering.--floyd SPREAD
Set dithering level (0-1).-v, --verbose
Verbose output.-
Read from stdin, write to stdout.NUM
Maximum number of colors (default: 256).
CAVEATS
Lossy compression - some quality is lost. 256 color maximum limits complex images. Photographs may not compress well. Original transparency is preserved but reduced to 8-bit. Metadata stripped by default. Results vary significantly by image content.
HISTORY
pngquant was created by Greg Roelofs around 1997 with the original PNG specification work. The project was later taken over by Kornel Lesinski who rewrote it with the libimagequant library around 2011. It became essential for web optimization, used in build tools and image CDNs to reduce bandwidth.
SEE ALSO
optipng(1), oxipng(1), imagemagick(1), jpegoptim(1)
