OPTIPNG(1)
๐ฆ OPTIPNG(1) โ OptiPNG Manual ๐ฆ
okay bestie, welcome to the OptiPNG manual, and no cap this is the glow-up your PNGs have been begging for ๐
โจ NAME โจ
optipng โ optimize Portable Network Graphics (PNG) files
like... it makes your PNGs skinnier. that's the whole job. she's an icon, she's a legend, and she's about to shrink ur files ๐ธ
๐ SYNOPSIS ๐
optipng [<options...>] [--] <files...>
๐ DESCRIPTION ๐
so the OptiPNG program shall attempt to optimize PNG files, i.e. to reduce their size to a minimum, without losing semantic information. no quality lost, only bytes lost โจ
on top of that, this program shall also perform a whole suite of auxiliary functions like integrity checks, metadata recovery and pixmap-to-PNG conversion. she does it all fr fr ๐
๐ซถ heads up tho: the optimization attempts are not guaranteed to succeed.
valid PNG files that cannot be optimized by this program are normally left intact โ their size will not grow. the user may request to override this default behavior. (that's the -force option, we'll get there ๐)
๐ FILES ๐
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 the image is in PNG format:
it attempts to optimize the given file in-place. if optimization is successful, or if the option -force is enabled, the original file will be replaced by its optimized version. in any case, the original file will be backed up if the option -keep is enabled. ๐ซถ
- if the image is in an external format:
it creates an optimized PNG version of the given file. the output file name will be constructed using the original file name and the .png extension. cute, right? ๐ฆ
aside from the rules stated above, any existing file is not overwritten, unless the option -clobber is enabled. (respect the existing files bestie, that's the default ๐ธ)
๐ OPTIONS ๐
๐ General options ๐
-?,-h,-helpโ show a complete summary of options. the "help me help you" trio ๐-backup,-keepโ keep a backup of the modified files. always protect the original, periodt.-clobberโ overwrite the existing output and backup files. under this option, if the option-backupis not enabled, the old backups of the overwritten files will be deleted. ๐ so yeah, be careful.-dirdirectory โ write the output files to directory.-fixโ enable error recovery. this option has no effect on valid input files. the program will spend a reasonable amount of effort to recover as much data as possible, without increasing the output file size, but the success cannot be generally guaranteed. the program may even increase the file size, e.g., by reconstructing missing critical data. under this option, integrity shall take precedence over file size. when this option is not used, the invalid input files are left unprocessed.-forceโ enforce writing of a new output file. this option overrides the program's decision not to write such file, e.g. when the PNG input is digitally signed (usingdSIG), or when the PNG output becomes larger than the PNG input. main character energy: she writes the file anyway ๐ค-outfile โ write output file to file. the command line must contain exactly one input file.-preserveโ preserve file attributes (time stamps, file access rights, etc.) where applicable. ๐-quiet,-silentโ run in quiet mode. shhh ๐คซ-simulateโ run in simulation mode: perform the trials, but do not create output files. all vibes, no files โจ-vโ enable the options-verboseand-version.-verboseโ run in verbose mode. tell me EVERYTHING ๐ฃ๏ธ-versionโ show the copyright, version and build info.--โ stop option switch parsing. the "okay that's enough options" barrier ๐ง
๐ง PNG encoding and optimization options ๐ง
-olevel โ select the optimization level.- the optimization level 0 enables a set of optimization operations that require minimal effort. there will be no changes to image attributes like bit depth or color type, and no recompression of existing IDAT datastreams.
- the optimization level 1 enables a single IDAT compression trial. the trial chosen is what OptiPNG thinks it might be the most effective.
- the optimization levels 2 and higher enable multiple IDAT compression trials; the higher the level, the more trials.
the behavior and the default value of this option may change across different program versions. use the option -h to see the details pertaining to your specific version. iykyk ๐
-ffilters โ select the PNG delta filters. the filters argument is specified as a rangeset (e.g.-f0-5), and the default filters value depends on the optimization level set by the option-o. the filter values0,1,2,3and4indicate static filtering, and correspond to the standard PNG filter codes (None, Left, Up, Average and Paeth, respectively). the filter value5indicates adaptive filtering, whose effect is defined by thelibpng(3)library used by OptiPNG.-fullโ produce a full report on IDAT. this option might slow down the trials. thorough but she takes her time ๐ข-itype โ select the interlace type (0-1). if the interlace type0is selected, the output image shall be non-interlaced (i.e. progressive-scanned). if the interlace type1is selected, the output image shall be interlaced using the Adam7 method. by default, the output shall have the same interlace type as the input.-nbโ do not apply bit depth reduction.-ncโ do not apply color type reduction.-npโ do not apply palette reduction.-nxโ do not apply any lossless image reduction: enable the options-nb,-ncand-np.-nzโ do not recode IDAT datastreams. the IDAT optimization operations that do not require recoding (e.g. IDAT chunk concatenation) are still performed. this option has effect on PNG input files only.-zclevels โ select the zlib compression levels used in IDAT compression. the levels argument is specified as a rangeset (e.g.-zc6-9), and the default levels value depends on the optimization level set by the option-o. the effect of this option is defined by thezlib(3)library used by OptiPNG.-zmlevels โ select the zlib memory levels used in IDAT compression. the levels argument is specified as a rangeset (e.g.-zm8-9), and the default levels value depends on the optimization level set by the option-o. the effect of this option is defined by thezlib(3)library used by OptiPNG.-zsstrategies โ select the zlib compression strategies used in IDAT compression. the strategies argument is specified as a rangeset (e.g.-zs0-3), and the default strategies value depends on the optimization level set by the option-o. the effect of this option is defined by thezlib(3)library used by OptiPNG.-zwsize โ select the zlib window size (32k,16k,8k,4k,2k,1k,512,256) used in IDAT compression. the size argument can be specified either in bytes (e.g.16384) or kilobytes (e.g.16k). the default size value is set to the lowest window size that yields an IDAT output as big as if yielded by the value32768. the effect of this option is defined by thezlib(3)library used by OptiPNG.
๐ธ Editing options ๐ธ
-snipโ cut one image out of multi-image, animation or video files. depending on the input format, this may be either the first or the most relevant (e.g. the largest) image. โ๏ธ-stripobjects โ strip metadata objects from a PNG file. PNG metadata is the information stored in any ancillary chunk excepttRNS. (tRNSrepresents the alpha channel, which, even if ignored in rendering, is still a proper image channel in the RGBA color space.) the only option currently supported is-strip all.
๐ Notes ๐
options may come in any order (except for --), before, after, or alternating with file names. option names are case-insensitive and may be abbreviated to their shortest unique prefix. slay, flexible queen ๐
some options may have arguments that follow the option name, separated by whitespace or the equal sign (=). if the option argument is a number or a rangeset, the separator may be omitted. for example:
optipng -out newfile.png <=> optipng -out=newfile.png
optipng -o3 <=> optipng -o 3 <=> optipng -o=3
optipng -f0,3-5 <=> optipng -f 0,3-5 <=> optipng -f=0,3-5
rangeset arguments are cumulative. for example:
optipng -f0 -f3-5 <=> optipng -f0,3-5
optipng -zs0 -zs1 -zs2,3 <=> optipng -zs0-3
๐ EXTENDED DESCRIPTION ๐
the PNG optimization algorithm consists of the following steps:
- reduce the bit depth, the color type and the color palette of the image. this step may reduce the size of the uncompressed image, which, indirectly, may reduce the size of the compressed image (i.e. the size of the output PNG file).
- run a suite of compression methods and strategies and select the compression parameters that yield the smallest output file.
- store all IDAT contents into a single chunk, eliminating the overhead incurred by repeated IDAT headers and CRCs.
- set the zlib window size inside IDAT to a minimum that does not affect the compression ratio, reducing the memory requirements of PNG decoders.
not all of the above steps need to be executed. the behavior depends on the actual input files and user options.
step 1 may be customized via the no-reduce options -nb, -nc, -np and -nx. step 2 may be customized via the -o option, and may be fine-tuned via the options -zc, -zm, -zs and -zw. step 3 is always executed. step 4 is executed only if a new IDAT is being created, and may be fine-tuned via the option -zw.
extremely exhaustive searches are not generally expected to yield significant improvements in compression ratio, and are recommended to advanced users only. so like... don't come for me if -o7 takes forever, bestie ๐ญ
โญ EXAMPLES โญ
optipng file.png # default speed
optipng -o5 file.png # slow
optipng -o7 file.png # very slow
pick ur fighter: chill, patient, or "i have time today" ๐โจ
๐ BUGS ๐
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.
- the bit depth reductions below
8, for grayscale images, are not implemented yet.
encoding of images whose total IDAT size exceeds 2GB is not currently supported.
TIFF support is limited to uncompressed, PNG-compatible (grayscale, RGB and RGBA) images.
metadata is not imported from the external image formats.
there is no support for pipes, streams, extended file attributes or access control lists.
ngl, she's still growing into her full power ๐ฑ but the integrity stays intact, periodt.
๐ฅ SEE ALSO ๐ฅ
png(5), libpng(3), zlib(3), pngcrush(1), pngrewrite(1).
...and that's part 1, bestie โ more coming, don't go anywhere ๐
๐ STANDARDS
Okay bestie, vibe check on compatibility real quick: the files OptiPNG spits out are compliant with the most recent PNG standard (they call it "PNG Second Edition") โจ and also with the most recent PNG draft standard (aka "PNG Third Edition") ๐ . Like, both. Simultaneously. Iconic behaviour, honestly.
- Portable Network Graphics (PNG) Specification, Second Edition. W3C Recommendation 10 November 2003; ISO/IEC IS 15948:2003 (E).
https://www.w3.org/TR/2003/REC-PNG-20031110/ - Portable Network Graphics (PNG) Specification, Third Edition. W3C Proposed Recommendation 15 May 2025.
https://www.w3.org/TR/2025/PR-png-3-20250515/
๐ AUTHORS
Screaming, crying, throwing up โ OptiPNG is written and maintained by Cosmin Truta ๐. Legend behaviour. No notes.
And this manual page you're reading rn? It was originally written by Nelson A. de Oliveira for the Debian Project ๐ซถ, then later updated by Cosmin Truta, and it is now part of the OptiPNG distribution. A whole collaborative storyline, fr fr. ๐ฆ
๐ that's the whole page, bestie โ go forth and optimise your PNGs, you absolute main character ๐ธ
optipng 7.9.1 ยท 2025-05-20 ยท OPTIPNG(1) ๐โจ bye ily ๐ซถ
๐ฆ where this page comes from
- alpine 3.24: optipng-doc 7.9.1-r1 ยท Zlib
- arch rolling: optipng 7.9.1-1 ยท ZLIB
- epel 10: optipng 7.9.1-1.el10_1 ยท zlib
- epel 9: optipng 7.9.1-1.el9 ยท zlib
- fedora 43: optipng 7.9.1-2.fc43 ยท zlib
- fedora 44: optipng 7.9.1-3.fc44 ยท zlib
- nixos 26.05: optipng 7.9.1
- nixpkgs unstable: optipng 7.9.1
- ubuntu questing: optipng 7.9.1+ds-2
- ubuntu resolute: optipng 7.9.1+ds-2build1 ยท Zlib
- ubuntu stonking: optipng 7.9.1+ds-2build1 ยท Zlib
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms