OptiPNG − Advanced optimization program for Portable Network Graphics (PNG) |
optipng [−? | −h |
−help] |
OptiPNG is a PNG optimizer that recompresses image files to a smaller size without losing any information. In addition, this program performs a suite of useful functions like integrity checks, meta-data recovery and pixmap-to-PNG conversion. |
The input files are raster image files encoded either in PNG format (the native format), or in an external format. The currently supported external formats are GIF, BMP, PNM and TIFF. OptiPNG processes each image file given in the command line as follows: − If it is in PNG format: |
Attempt to optimize the given file in-place. If optimization is successful, or if the option −force is in effect, replace the original file with its optimized version. The original file is backed up if the option −keep is in effect. |
− If it is an external format: |
Create an optimized PNG version of the given file. The output file name is composed from the original file name and the .png extension. |
Basic options |
-?, −h, −help |
Show a complete summary of options. |
−o level |
Select the optimization level. |
−i type |
Select the interlace type (0−1). |
−k, −keep |
Keep a backup of the modified file(s). |
−q, −quiet |
Run in quiet mode. |
−v |
Show copyright, version and build info; run in verbose mode. |
Advanced options |
−zc levels |
Select the zlib compression levels. |
−zm levels |
Select the zlib memory levels. |
−zs strategies |
Select the zlib compression strategies. |
−zw window size |
Select the zlib window size
(32k,16k,8k,4k,2k,1k,512,256). |
−f filters |
Select the PNG delta filters. |
−nb |
Do not apply bit depth reduction. |
||
−nc |
Do not apply color type reduction. |
||
−np |
Do not apply palette reduction. |
||
−nz |
Do not perform IDAT recompression (also disable reductions). |
||
−fix |
Enable error recovery. |
||
−force |
Enforce writing of a new output file. Use this option to override the program’s decision not to write such file, e.g. when the PNG input is digitally signed (using dSIG), or when the PNG output becomes larger than the PNG input. |
||
−full |
Produce a full report on IDAT. This option might slow down the trials. |
−preserve |
Preserve file attributes (time stamps, file access rights, etc.) where applicable. |
−simulate |
Run in simulation mode: perform the trials, but do not create output files. |
−snip |
Cut one image out of multi-image, animation or video file(s). Depending on the input format, this may be either the first or the most relevant (e.g. the largest) image. |
−out file |
Write output file to file. The command line must not contain more than one input file. |
−dir directory |
Write output file(s) to directory. |
−log file |
Log messages to file. For safety reasons, file must have the extension .log. |
−− |
Stop option switch parsing. |
Notes |
The option names are case-insensitive and can be abbreviated. Any abbreviation must uniquely identify the full option name and must be no shorter than two letters, unless one letter is explicitly permitted. For example, −quiet can be abbreviated as −q or −qu (because −q is explicitly mentioned in the list of possible options), while −preserve can be abbreviated as −pr but not as −p. Some options may have arguments that follow the option name, with or without a whitespace used as a separator; e.g. |
−i1 <=> −i 1 |
Range arguments are cumulative; e.g. |
−f0 −f3−5 <=>
−f0,3−5 |
The zlib window size is automatically set to a minimum that does not affect the compression ratio. The output files will have all IDAT in a single chunk, even if no recompression is performed. Extremely exhaustive searches are not generally recommended. |
optipng file1.png file2.gif file3.tif |
optipng −o5 file1.png file2.gif file3.tif |
optipng −i1 −o7 −v −full −sim experiment.png −log experiment.log |
Lossless image reductions are not completely implemented. (This does NOT affect the integrity of the output files.) Here are the missing pieces: |
− The color palette reductions are implemented only
partially. |
TIFF support is limited to uncompressed, PNG-compatible (grayscale, RGB and RGBA) images. Metadata is not imported from the external image formats. |
png(5), libpng(3), zlib(3), pngcrush(1), pngrewrite(1). Glenn Randers-Pehrson et al. Portable Network Graphics
(PNG) Specification, Second Edition. |
OptiPNG is written and maintained by Cosmin Truta. This manual page was originally written by Nelson A. de Oliveira for the Debian Project. It was later updated by Cosmin Truta, and is now part of the OptiPNG distribution. |