PNGquant is one of best tool for lossy compression of PNG images. Its reduce the PNG image size upto 70% and maintain full alpha transparency.

Easy to convert large number of images,

Easy to integrate server side with shell script

Default pngquant installation path is, /usr/local/bin/pngquant

download  and Installation:

# wget

# cd pngquant-2.4.0

# ./configure --with-openmp --with-lcms2

 Compiler: gcc
     Debug: no
       SSE: yes
    OpenMP: yes
    libpng: shared (1.2.49)
      zlib: shared (1.2.3)
     lcms2: error ... not found (please install libcms2-devel package)

Error :lcms2-devel packages could not found it just following below steps,


 Download the latest epel-release rpm from

Install epel-release rpm:
# rpm -Uvh

Install lcms2-devel rpm package:
# yum install lcms2-devel -y

Then try again,

#  ./configure --with-openmp --with-lcms2

 Compiler: gcc
     Debug: no
       SSE: yes
    OpenMP: yes
    libpng: shared (1.2.49)
      zlib: shared (1.2.3)
     lcms2: shared (2.3)

To find the version:
# pngquant --version
2.4.0 (March 2015)

# pngquant --help

How to Use pngquant?

For example convert a .png file format, just see the image file size,before conversion,
# du -sch thelinuxfaq_pngquant.png
40K     thelinuxfaq_pngquant.png

# pngquant  -ext .png --force yourimage.png

Aftet conversion,
# du -sch thelinuxfaq_pngquant.png
22K     thelinuxfaq_pngquant.png

Also, can convert with quality based,
# pngquant  -ext .png --quality 30-50 --force yourimage.png

 --force                 overwrite existing output files (synonym: -f)
 --ext new.png        set custom suffix/extension for output filenames
 --quality min-max    don't save below min, use fewer colors below max (0-100)

Before conversion file size,
# du -sch /home/thelinuxfaq/png-images

88K     linuxfaq.png
88K     thelinux_faq.png
88K     the_linux.png
# find . -name '*.png' -exec pngquant -ext .png -force 256 {} \;

After conversion files size,
# du -sch *

40K     linuxfaq.png
40K     thelinux_faq.png
40K     the_linux.png

How to use for PHP:

The below sample code for conversion with exec

 echo $get_compress = exec("find /image/source/path -name '*.png' -exec /usr/local/bin/pngquant -ext .png -force 256 {} \;");