pngcrush 1.5.10
|
|
Developer(s) | Glenn Randers-Pehrson |
---|---|
Stable release |
1.8.2 / 11 July 2016
|
Written in | C |
Operating system | Cross-platform |
Type | Image optimizer |
License | Similar to libpng License |
Website | pmt |
pngcrush is a free and open source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly – that is, the resulting "crushed" image will have the same quality as the source image.
The main purpose of pngcrush is to reduce the size of the PNG IDAT data stream by trying various combinations of compression methods and delta filters. It can also be used for various manipulations of PNG images, such as changing the bit depth, removing unwanted ancillary chunks, or adding certain chunks including gAMA, tRNS, iCCP, and textual chunks.
The main use of pngcrush is for reducing the size of the image data contained in the IDAT section.
The pixel data in a PNG file is compressed using LZ77 algorithm (which tries to find repeated byte sequences in the source data), and then further compressed with Huffman algorithm. This combination is referred to as DEFLATE compression. Before compressing, non-destructive delta filters are applied on the pixel data.
There are five possible filter types that can be specified separately on each scan line and several possible strategies for searching LZ77 matches. Thus, there are a very large number of different combinations for how the image can be compressed. Which combination gives the best compression will depend on the individual image's properties.
pngcrush compresses the image with multiple different combinations and then stores the smallest of the resulting files. Since it is not possible to go through all the combinations, pngcrush uses heuristics to choose the methods to try.
In the simplest form, pngcrush can be told to generate a "crushed" file from an unoptimized one by using the following format on the command line:
By default, pngcrush uses just a few common methods to crush the file. The optional "-brute" argument can be used for brute force crushing, which will try 148 different crushing methods.