Last time we talked about jpegoptim, jpegtran and optipng. Today we’re going to talk about pngcrush – an optimizer for PNG (Portable Network Graphics) files. pngcrush can be run from a command line in an MSDOS window, or from a UNIX or LINUX command line.
Installation of pngcrush
On Debian, this utility is included in packages:
# apt-get install pngcrush
Usage of pngcrush
For maximum compression without loss of quality use this command to compress a png file as much as possible:
# pngcrush -rem alla -rem text -reduce -brute in.png out.png
during this action, in.png file will be optimized and the result saved in out.png
Parameters
1. A simple option for automatic optimization:
# pngcrush -reduce -brute in.png out.png
2. Also, pngcrush can remove all color correction data from a file:
# pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB in.png out.png
3. Data that supported may also be deleted:
# pngcrush -rem alla -rem text in.png out.png
Optimization of all pictures in a folder
For maximum optimization of all images in a folder, use the following command:
for file in * .png do pngcrush -reduce -brute -rem alla -rem gAMA -rem cHRM -rem iCCP -rem sRGB "$ file" "$ {file% .png} -crushed.png" && mv "$ {file% .png} -crushed .png "" $ file " done