pngcrush
Optimize PNG image file size
TLDR
Compress a PNG file
Compress all PNGs and output them to the specified directory
Compress PNG file with all 114 available algorithms and pick the best result
SYNOPSIS
pngcrush [options] <infile.png> [outfile.png]
PARAMETERS
-a max|all
Set maximum number of alpha values or try all
-b
Backup original input file
-brute
Try every possible combination of compression (very slow)
-d <dir>
Output files to specified directory
-e <ext>
Use custom output file extension
-f
Force overwrite of existing output file
-fix
Fix CRC errors in ancillary chunks
-i <num>
Number of compression trials (0=auto)
-l <0-9>
Zlib compression level (default 1)
-m <num>
Maximum IDAT chunk size
-n
No changes, just copy (for testing)
-nofix
Do not fix CRC errors
-pause
Pause before overwriting files
-q
Quiet mode, suppress output
-reduce
Reduce image to grayscale or indexed color
-rem <chunklist>
Remove specified ancillary chunks
-rem all
Remove all ancillary chunks
-s <0-3>
Zlib compression strategy
-v
Verbose output
-z <0-15>
Zlib compression method
DESCRIPTION
Pngcrush is a powerful command-line tool for optimizing PNG files by minimizing their size without losing any image data or quality.
It works by experimenting with different compression parameters for the PNG's IDAT data streams, including various Zlib compression levels, strategies, and window sizes. Additionally, it can simplify palettes, remove or preserve ancillary chunks (like text metadata, gamma, or transparency info), and fix common PNG issues such as CRC errors.
Ideal for web developers, game developers, and anyone needing to reduce PNG file sizes for faster loading or storage efficiency. The tool supports batch processing and can output to a different directory or extension. While fast for basic optimizations, exhaustive modes like -brute can take significant time on large images but yield the smallest files.
Developed as part of the PNG ecosystem, pngcrush often outperforms standard PNG encoders and is widely used in build pipelines. It preserves all visual information, making it truly lossless.
CAVEATS
Brute-force modes (-brute) are extremely slow on large images; may increase size if palette reduction fails; does not support animated PNGs (APNG); output may vary slightly in decoding due to compression differences.
EXAMPLE USAGE
pngcrush -reduce -rem alla input.png output.png
Optimizes with palette reduction and removes all metadata.
pngcrush -brute input.png
Overwrites input with brute-force smallest size.
INSTALLATION
Available via package managers: apt install pngcrush (Debian/Ubuntu), yum install pngcrush (RHEL), or brew install pngcrush (macOS). Source at libpng.org.
HISTORY
Created by Glenn Randers-Pehrson in 1999 as pngcrush v1.0; actively maintained until 2018 (v1.8.13); integral to libpng suite for PNG optimization; widely adopted since early 2000s for web and graphics workflows.


