oxipng
Optimize PNG image file size
TLDR
Compress a PNG file (overwrites the file by default)
Compress a PNG file and save the output to a new file
Compress all PNG files in the current directory using multiple threads
Compress a file with a set optimization level (default is 2)
Set the PNG interlacing type (0 removes interlacing, 1 applies Adam7 interlacing, keep preserves existing interlacing; default is 0)
Perform additional optimization on images with an alpha channel
Use the much slower but stronger Zopfli compressor with max optimization
Strip all non-critical metadata chunks
SYNOPSIS
oxipng [options] file1.png [file2.png ...]
PARAMETERS
-o
Optimization level (0-6). Higher levels try more optimization strategies but take longer. Default is 2.
-i
Maximum number of optimization iterations to perform. Default is determined by the optimization level.
-d
Reduce bit depth if possible. Values can be: 8, 4, 2, 1 or auto. Default is auto.
-nc
No color type reduction.
-nr
No rectangle filter.
-nz
No zopfli algorithm
-strip
Strip metadata chunks. 'safe' removes only non-critical chunks. 'all' removes all non-essential chunks.
-k
Keep specified metadata keywords.
-f
Specify filter(s) to try. Examples: 0, 0-4, 0-4,8;1-3;9, or default.
-rc
Specify deflate compression levels. Example: 6,8,9.
-nx
Do not use the Adam7 interlacing scheme.
-cx
Convert to Adam7 interlacing scheme.
-q
Quiet mode; suppress progress messages.
-v
Verbose mode; print detailed information.
-h
Display help message.
-V
Display version information.
DESCRIPTION
oxipng is a command-line tool designed to losslessly optimize PNG (Portable Network Graphics) image files. It uses a variety of techniques, including trying different compression methods and filter strategies, to achieve the smallest possible file size without altering the image's visual appearance.
The primary goal of oxipng is to reduce the storage space required for PNG images, which is particularly useful for web developers, graphic designers, and anyone dealing with a large number of PNG files. By aggressively optimizing images, oxipng can improve website loading times, reduce bandwidth consumption, and save disk space. The tool is known for its efficiency and ability to often achieve better compression ratios than other PNG optimization tools, although this comes at the cost of increased processing time.
It supports various optimization levels to balance compression strength and speed, allowing users to choose the most appropriate setting for their specific needs. oxipng is typically used as part of an image optimization pipeline or as a standalone tool for optimizing individual PNG files.
CAVEATS
oxipng can be computationally intensive, especially at higher optimization levels. This can lead to significantly longer processing times, particularly for large images. Always test optimized images to ensure they are displaying correctly, although the lossless nature of oxipng is intended to prevent visual changes.
EXIT CODES
oxipng returns 0 on success. Non-zero exit codes indicate errors such as file access problems or invalid parameters.
EXAMPLES
Optimize a single PNG file with the default optimization level:
oxipng image.png
Optimize with maximum effort, stripping all safe metadata:oxipng -o 6 -strip safe image.png
Optimize with a specific filter set and compression level:oxipng -f 0,5 -rc 9 image.png
HISTORY
oxipng was created as a faster and more efficient alternative to existing PNG optimization tools. It gained popularity due to its ability to achieve higher compression ratios in many cases. The development continues to focus on improving speed, reducing memory usage, and adding new optimization techniques. It is widely used in automated image processing pipelines and web development workflows.