oxipng

multithreaded PNG optimization tool written in Rust

TLDR

Optimize PNG file
$ oxipng [image.png]
Optimize with maximum compression
$ oxipng -o max [image.png]
Optimize and write to a different file
$ oxipng --out [output.png] [input.png]
Optimize all PNGs in directory
$ oxipng [*.png]
Strip all metadata
$ oxipng --strip all [image.png]
Use multiple threads
$ oxipng -t [4] [image.png]
Reduce to 8-bit palette if possible
$ oxipng --reduce [image.png]
Dry run (show savings without writing)
$ oxipng --pretend [image.png]

SYNOPSIS

oxipng [-o level] [--strip mode] [-t threads] [--reduce] [options] files

DESCRIPTION

oxipng is a multithreaded PNG optimization tool written in Rust. It reduces PNG file sizes through lossless recompression without affecting image quality.Optimization levels (0-6) control the trade-off between compression and speed. Level 2 is default, providing good compression quickly. Level 6 and "max" try more strategies for maximum compression but take longer.The tool tries different PNG filter strategies and compression parameters to find the smallest output. Metadata stripping further reduces size - "safe" removes non-essential chunks, "all" removes everything except critical image data.Bit depth reduction automatically converts 16-bit to 8-bit or RGBA to palette when possible without quality loss. This can significantly reduce file sizes for suitable images.Zopfli mode uses a more exhaustive compression algorithm for ~5% better compression at the cost of much longer processing time. This is useful for images that will be served repeatedly.

PARAMETERS

-o, --opt LEVEL

Optimization level (0-6, max).
-s, --strip MODE
Strip metadata: none, safe (non-rendering metadata), all (everything non-critical). -s alone is shorthand for --strip safe.
-a, --alpha
Additional alpha optimizations.
-t, --threads NUM
Number of threads.
--out DIR
Output directory.
--dir DIR
Recursively process directory.
-r, --recursive
Process directories recursively.
--reduce
Attempt bit depth reduction.
--interlace MODE
Interlacing: 0 (none), 1 (Adam7), keep.
--pretend
Dry run, show savings without writing.
-b, --backup
Keep backup of original file.
-f NUM, --filters NUM
Filter strategies to try (0=None, 1=Sub, 2=Up, 3=Average, 4=Paeth, 5=MinSum, 6=Entropy, 7=Bigrams, 8=BigEnt, 9=Brute). Supports comma-separated lists or ranges (e.g., 0-5).
-Z, --zopfli
Use Zopfli for better compression (much slower).
--timeout seconds
Maximum time to spend optimizing a single file.
--check
Verify output integrity.
-q, --quiet
Quiet mode.
-v, --verbose
Verbose output.

INSTALL

sudo dnf install oxipng
sudo pacman -S oxipng
sudo apk add oxipng
sudo zypper install oxipng
brew install oxipng
nix profile install nixpkgs#oxipng

CAVEATS

Cannot reduce file size if PNG is already optimally compressed. Zopfli mode is very slow. Maximum optimization level uses significant CPU time. Some PNG features may not be fully supported. Large images need substantial memory.

HISTORY

oxipng was created by Josh Holmer around 2016 as a Rust rewrite of OptiPNG. The goal was to provide a faster, multithreaded PNG optimizer with modern code. It has become popular for build pipelines and asset optimization, particularly in web development where PNG size directly affects page load times.

SEE ALSO

optipng(1), pngcrush(1), pngquant(1), zopflipng(1)