|Original author(s)||Kornel Lesiński|
|Written in||C (C99)|
|Type||Image compression software|
|License||GNU GPL v3|
pngquant is a handy command-line utility for PNG images capable of reducing the file size to a fraction of the original using lossy compression. It can optionally do Floyd-Steinberg dithering to reduce the palette, further reducing the file size. PNG files processed by pngquant are typically between half and a third of the original image files size.
pngquant will reduce a PNG images palette. 32-bit RGBA PNGs are reduced to 8-bit or less, 8-bit images have their palette reduced, if possible, to the number of bits actually needed.
pngquant supports compression levels ranging from 1 (best) to 11 (worst). It defaults to level 3. Floyd-Steinberg dithering is enabled by default. It can be disabled by setting
--floyd to 0.
pngquant is as easy as running
pngquant imagefile.png. pngquant will save the new image file as
pngquant supports wildcards for batch compression of multiple images (
pngquant *.png). You can also use
We occasionally serve advertisements from the Humble Bundle affiliate program on this website. They provide their banners as rather large (in file size) PNG images. The table below shows the effect of using
pngquant with default options on those images:
|File||Original PNG image||PNG, after pngquant||JPG||WebP|
The original PNG images are, in the case of that particular class of computer graphics, 3.5-4.2 times as large as the visually identical images
When To Use pngquant And When To Not Bother
pngquant is very useful in all cases where you need to distribute one or several PNG image files to a larger audience. Half a megabyte or just a few hundred kilobytes adds up if the same image is downloaded by thousands of users viewing a website.
pngquant to compress PNG images meant for the web is only useful if the actual file you upload to a website is used. That is often not the case. Sites like using the MediaWiki content management system, like this one, is one practical example where pngquant is a complete and utter waste of time. The reason is that many content management systems will mostly use re-sized self-generated image files instead of the uploaded image file.
Consider a 818x823 pixel 116702 bytes file called
xfce-power-manager.png as an exmaple.
pngquant xfce-power-manager.png creates a 40195 bytes large file named
xfce-power-manager-fs8.png. The pngquant reduced file is just 34% of the original file size. That's a very nice achievement. Running
xfce-power-manager-fs8.png through the ImageMagick convert tool and reducing the physical image size from 818x823 pixels to 800x805 with
convert xfce-power-manager-fs8.png -resize 800 xfce-power-manager-800x.png creates a new 206736 bytes large PNG file. That's 2x the size of the original file (even though it has fewer pixels) and it is five times as large as the file pngquant produced.
Using a JPEG or WebP image file is usually a lot better than a pngquant compressed PNG if you are uploading a file to a content management system that does not use the actual uploaded file. Using
pngquant is almost a requirement if' the actual file you upload is used directly.
pngquant has a homepage at pngquant.org.