Pngquant examples - optimizing png images

Last updated:

Pngquant is used to to reduce the size (in Kb) of PNG images, by reducing the number of different colors. As much as 70% size reduction is usually achieved.

Most images on this web site are processed with pngquant

This is useful because most images don't need high resolution to look good on the web.

download on ubuntu

pngquant can be downloaded from the ubuntu repository:

sudo apt-get install pngquant

or from the official pngquant homepage

Reduce the number of colours in an image to 32

pngquant 32 myimage.png

You can of course replace 32 with the desired amount of colours - more colours result in higher quality images but the size reduction is not so aggressive.

From my experience, using 64 colours is a good tradeoff between image size and quality.

Example image

See this image, its size is 75,6 Kb:

image-original Original PNG image, size: 75.6 Kb

Now this is the image after its number of colours has been reduced to 32, with a command like pngquant 32 ducati.png:

image-after Modified PNG image, size: 12 Kb. This is a reduction of 84% in size, with respect to the original image!

Other options

  • --ext name.png

    Use name.png as the output image name. Default is to use the same name as the original and append -fs8.png to it.

  • --quality 99

    Instructs pngquant to use as few colours as it can to achieve 99% quality in the output image. 100 means best possible quality, i.e. no size reduction at all.

Dialogue & Discussion