From Wikipedia, the free encyclopedia

Jump to: navigation, search
pngcrush screenshot
pngcrush 1.5.10
Developed by Glenn Randers-Pehrson
Latest release 1.6.14 (executable) / 2009-02-20; 42 days ago
Written in C
Operating system Cross-platform
Type Image optimizer
License OSI Approved License

pngcrush is an open source, free command line computer program that reduces the size of PNG files. The compression is lossless, meaning that the resulting image will have the same quality as the source image. The main purpose of pngcrush is to reduce the size of the PNG IDAT datastream by trying various compression levels. However, pngcrush can also be used for various manipulations of PNG images, such as changing the bit depth.

There is an optional "-brute" option, which performs a brute force crush when set: rather than use one of a few common methods to crush the file, it will try all of them.


[edit] Main operation

The main use of pngcrush is for reducing the size of the image data contained in the IDAT section. PNG uses DEFLATE compression which can vary in speed and compression ratio, from nearly no compression at all but at very high speed to the very good compression ratio, albeit at a lower speed. The PNG compressors built into many paint programs may not always apply the maximum amount of compression possible, and it is on images from these programs that pngcrush performs best.

pngcrush generates an "optimised" file from an unoptimised one using the following format on the command line:

pngcrush imageIn.png imageOut.png

pngcrush may not always generate the smallest PNG file possible. Because of different or more exhaustive search strategies being used, some other programs may give better results by several percent on certain files[citation needed]. OptiPNG, AdvanceCOMP and PNGOUT, for example, can sometimes outperform pngcrush in regards to PNG file sizes, although the time taken (and in some cases, the required manual labour on the user's behalf) to reach the result is usually increased.

[edit] Reducing filesize by removing color-correction data

pngcrush has one advantage over the other programs because it can remove all the color-correction data (gamma, white balance, ICC color profile, standard RGB color profile) from PNG files, using the following command line options:

pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB InputFile.png OutputFile.png

Since most graphics software embed the extra color-correction data, which is normally not needed, this can produce file sizes that are up to 40 % smaller than the original. Greater reductions come from PNG images that have 256 colors or less (indexed color).

[edit] Image manipulation

pngcrush can be used to change the parameters of an image. For example, if an image contains 10 colours but has a colour palette of 256 entries (8-bit), pngcrush can be used to reduce the colour palette to a 4-bit one and truncate the palette to 10 entries:

pngcrush -bit_depth 4 -plte_len 10 image1.png image2.png

pngcrush can also change the colour type of the image. For a truecolour image, changing the colour type from 2 to 0 (-c 0) converts it to greyscale. For a truecolour-alpha image, changing the colour type from 6 to 2 removes the alpha channel.

[edit] Chunk and metadata manipulation

PNG images contain chunks with information about the image, such as its resolution (the phys chunk), the time it was last modified (the tIME chunk) and textual metadata (the text chunk and its variants). With pngcrush the user can edit or remove those ancillary chunks:

pngcrush -res 96 -rem time -text b "Software" "pngcrush" image1.png image2.png

The above command sets the image resolution to 96 dpi, removes the timestamp and writes a textual metadata chunk describing pngcrush as the creation software of the image.

[edit] See also

Similar PNG compression programs include:

[edit] External links

Personal tools