Pngcrush is an optimizer for PNG (Portable Network Graphics) files. pngcrush is an excellent batch-mode compression utility for PNG images. Depending on the application that created the original PNGs, it can improve the file size anywhere from a few percent to 40% or more (completely losslessly). The utility also allows specified PNG chunks (e.g. text comments) to be inserted or deleted, and it can fix incorrect gamma info written by Photoshop 5.0 as well as the erroneous iCCP chunk written by Photoshop 5.5. 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.
It is a Command Line utility for Linux/Unix or for Windows (from DOS).
Install PNGCRUSH
To install pngcrush, click this for pngcrush from Packman. This will download the YaST Meta Package file (YMP file) and lauch it with the YaST Package Manager.
NOTE: Click here to enable 1-click feature in openSUSE 10.2
Click Next on the package selection window showing “pngcrush” and next again in the window showing summary of repositories and package selection. This will add the required repositories and download and install pngcrush as well as the required dependencies. Once installed, click Finish.
This will install “pngcrush” under /usr/bin/
opensuse11:~ # which pngcrush
/usr/bin/pngcrush
To simply compress a PNG file syntax is
pngcrush <inputfile> <outputfile>
For example
opensuse11:~ # pngcrush saihari.png saihari2.png
| pngcrush 1.6.10
| Copyright (C) 1998-2002,2006-2008 Glenn Randers-Pehrson
| Copyright (C) 2005 Greg Roelofs
| This is a free, open-source program. Permission is irrevocably
| granted to everyone to use this version of pngcrush without
| payment of any fee.
| Executable name is pngcrush
| It was built with libpng version 1.2.31, and is
| running with libpng version 1.2.31 – August 21, 2008| Copyright (C) 1998-2004,2006-2008 Glenn Randers-Pehrson,
| Copyright (C) 1996, 1997 Andreas Dilger,
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
| and zlib version 1.2.3.3, Copyright (C) 1998-2002 (or later),
| Jean-loup Gailly and Mark Adler.
| It was compiled with gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036].Recompressing saihari.png
Total length of data found in IDAT chunks = 11179794
unknown chunk handling done.
IDAT length with method 1 (fm 0 zl 4 zs 0) = 19493337
IDAT length with method 2 (fm 1 zl 4 zs 0) = 12357096
IDAT length with method 3 (fm 5 zl 4 zs 1) = 11558196
IDAT length with method 9 (fm 5 zl 2 zs 2) = 11560585
IDAT length with method 10 (fm 5 zl 9 zs 1) = 11165952
Best pngcrush method = 10 (fm 5 zl 9 zs 1) for saihari2.png
(0.12% IDAT reduction)
(0.27% filesize reduction)CPU time used = 35.130 seconds (decoding 2.170,
encoding 32.740, other 0.220 seconds)opensuse11:/home/saibaba/pics # ls -l saihari*
-rw-r–r– 1 saibaba users 11196272 Jul 26 12:50 saihari.png
-rw-r–r– 1 root root 11166314 Jul 26 12:50 saihari2.png
For advanced options, simply type “pngcrush” from prompt without any file names.
opensuse11:~ # pngcrush
…
..
.
usage: pngcrush [options] infile.png outfile.png
pngcrush -e ext [other options] files.png …
pngcrush -d dir [other options] files.png …
options:
-already already_crushed_size [e.g., 8192]
-bit_depth depth (bit_depth to use in output file)
-brute (use brute-force: try 126 different methods [11-136])
-c color_type of output file [0, 2, 4, or 6]
-d directory_name (where output files will go)
-double_gamma (used for fixing gamma in PhotoShop 5.0/5.02 files)
-e extension (used for creating output filename)
-f user_filter [0-5]
-fix (fix otherwise fatal conditions such as bad CRCs)
-force (write a new output file even if larger than input)
-g gamma (float or fixed*100000, e.g., 0.45455 or 45455)
-huffman (use only zlib strategy 2, Huffman-only)
-iccp length “Profile Name” iccp_file
-itxt b[efore_IDAT]|a[fter_IDAT] “keyword”
-keep chunk_name
-l zlib_compression_level [0-9]
-loco (“loco crush” truecolor PNGs)
-m method [0 through 200]
-max maximum_IDAT_size [default 8192]
-mng (write a new MNG, do not crush embedded PNGs)
-nofilecheck (do not check for infile.png == outfile.png)
-n (no save; does not do compression or write output PNG)
-plte_len n (truncate PLTE)
-q (quiet)
-reduce (do lossless color-type or bit-depth reduction)
-rem chunkname (or “alla” or “allb”)
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
-res dpi
-rle (use only zlib strategy 3, RLE-only)
-save (keep all copy-unsafe chunks)
-srgb [0, 1, 2, or 3]
-ster [0 or 1]
-text b[efore_IDAT]|a[fter_IDAT] “keyword” “text”
-trns_array n trns[0] trns[1] .. trns[n-1]
-trns index red green blue gray
-v (display more detailed information)
-version (display the pngcrush version)
-w compression_window_size [32, 16, 8, 4, 2, 1, 512]
-z zlib_strategy [0, 1, 2, or 3]
-zmem zlib_compression_mem_level [1-9, default 9]
-zitxt b[efore_IDAT]|a[fter_IDAT] “keyword”
-ztxt b[efore_IDAT]|a[fter_IDAT] “keyword” “text”
-h (help and legal notices)
-p (pause)
1 Comment