The optimization of the compression of images is an important factor in speed of loading web pages. As I am in my period optimization, I sought a method to reduce the size of PNG.

Here are two absolutely essential tools:

Pngnq , to convert a PNG file with 256 colors by defining a color palette that best reflects the mood of the image.

Optipng him, several methods of compression tests to obtain a PNG image of an optimal size. It also removes all the useless information.

Then simply use the following commands to convert the image:

pngnq -vf -s1 image.png
optipng -o7 image-nq8.png

Note that pngnq saves the image as the image image.png-nq8.png. Finally, of course, if the reduction of color gives an image of very poor quality, we will use that optipng.

For example the image at the top of this article was originally 128kb and no longer than 33kb, yet the quality is correct.

For Linux users, I made ​​a small bash program to automate the commands:

#!/bin/bash
pngnq -vf -s1 $1.png
optipng -o7 $1-nq8.png
echo " Conversion Terminée !"

To use, enter the command. / Png.sh picture or "image" is the name of the image without the extension and png.sh the name of the file where I enter the script.

For installation on Linux (Debian, Ubuntu):

sudo apt-get install pngnq optipng

These programs are also available for Windows:

Source

Similar Items: