PNG “Portable Network Graphics”  is a image format designed to replace limitations of GIF image format in terms of data compression and color precision. The sizes of  PNGs image files can vary based on several factors like color depth , precompression filter, etc.

Optipng is a Linux command line script that performs multiple optimizations on PNG image files including size compression, integrity checks and more.
I will show you how to use and install Optipng on Debian Linux.

Step1. Install Optipng on Debian:

apt-get install optipng

Step2. Now you can compress a PNG image using the following command:

optipng -o 7 image.png

You can choose between 7 levels of compression from 0 to 7. The 7 level is very slow.

Now I will show you how to compress all images on your server:
First search all PNG images and put them into a list.

find /home/www/ -path -prune -o -name "*.png" > pngfiles.list Continue Reading...