LinuxCommandLibrary

oxipng

multithreaded PNG optimization tool written in Rust

TLDR

Optimize PNG file

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

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, all.
-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-5).
-z, --zopfli
Use Zopfli for better compression (slower).
--check
Verify output integrity.
-q, --quiet
Quiet mode.
-v, --verbose
Verbose output.

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

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community