Pngcrush is an optimizer for PNG (Portable Network Graphics) files. It can be run from a commandline in an MSDOS window, or from a UNIX or LINUX commandline.
Its main purpose is to reduce the size of the PNG IDAT datastream by trying various compression levels an PNG filter methods. It also can be used to remove unwanted ancillary chunks, or to add certain chunks including gAMA, tRNS, iCCP, and textual chunks.
Pngcrush is open source and may be used by anyone without fee.
The source code and binary executables for pngcrush are here. Pngcrush uses libpng and zlib, both of which are included in this pngcrush source distribution. They are slightly modified:
If you prefer, you can compile only pngcrush.c from the pngcrush source distribution and run it with the stock libpng and zlib, which can be found at the PNG web site, www.libpng.org/pub/png/. If you do this,
which will result in slightly larger files and slightly faster execution.
#define PNG_SETJMP_NOT_SUPPORTED #define PNG_ABORT()
Note that if you do this, you will need to recompile any old libpng-using applications if they make direct access to the png_ptr, because the define will make an incompatible change to the png structure.
Precompiled binaries for Windows (runs in MSDOS window, built under DJGPP) and RISCOS platforms are here.
The author of pngcrush is Glenn Randers-Pehrson,
An alternative to pngcrush (OptiPNG) is being developed by Cosmin Truta. OptiPNG makes better use of IO and uses a wider search space. The user interface is somewhat different from pngcrush's commandline interface. See http://www.cs.toronto.edu/~cosmin/pngtech/optipng/
Apple distributes a modified version of pngcrush (although it still claims to be the real pngcrush and does not inform the user of the changes, as they are required to do by the pngcrush license). It creates files that are not valid PNG datastreams, since they begin with the CgBI chunk instead of the IHDR chunk. The Apple-modified pngcrush is capable of reverting the "iPhone optimizations" (except for unavoidable loss of precision in the underlying color values of non-opaque pixels). There are also third-party applications such as the public domain, open source pngdefry application that can be found on the net. I am required to note that Apple and iPhone are registered trademarks of Apple, Inc.
This page has been translated into the
Spanish language by Maria Ramos
and into the
French language by Nicolas Chevallier.