linux poison RSS
linux poison Email

pngcrush - Optimize PNG file (image) to Speed up WebSite

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.

Pngcrush is not installed by default in Linux, but it is available in the repositories of most Linux distributions. In Ubuntu Linux, you can install pngcrush by running the following command :

$ sudo apt-get install pngcrush

OpenSuSe user can install Pngcrush using "1-click" installer - here

Using pngcrush
Running the Pngcrush command with no options may produce smaller files. Here is how we can use it to optimize and reduce size of PNG files -

$ pngcrush -brute -e "Optimize.png" filename.png

-brute – Use brute force, try 114 different filter/compression methods. This option is very time consuming but will able to reduce the size of PNG images by significant factor using this option.

-e "ext" – Specify a new extension for all output files. In the above example, the output of the command will be a file named filename Optimize.png . You can use any extension you want. This option ensures that the original file is not overwritten.

More examples
$ pngcrush -brute -d "/home/laf/images/pngcrush/"  *.png

All the files in the current directory are optimized and saved in the directory denoted by the -d option.


1 comments:

Anonymous said...

This script optimizes jpgs and pngs: http://lyncd.com/2009/03/imgopt-lossless-optimize-png-jpeg/

Gifs are pretty easy to add as well. I posted the code as a comment on the same site.

Post a Comment

Related Posts with Thumbnails