pngcrush for image optimization

Last time we were talked about jpegoptimjpegtran 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


A simple option for automatic optimization:

pngcrush -reduce -brute in.png out.png

Also, pngcrush can remove all color correction data from a file:

pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB in.png out.png

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

That’s all!

You can read more Linux guides by link

Viva La Linux!

Leave A Comment