pngquant

From LinuxReviews
Jump to navigationJump to search
pngquant
Pngquant-logo.png
Original author(s)Kornel Lesiński
Developer(s)Kornel Lesiński
Initial release2006
Repositorygithub.com /kornelski/pngquant
Written inC (C99)
Operating systemLinux
TypeImage compression software
(PNG only)
LicenseGNU GPL v3
Websitepngquant.org
Pngquant-logo.png

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.

Features[edit]

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.

Using pngquant is as easy as running pngquant imagefile.png. pngquant will save the new image file as imagefile-fs8.png.

pngquant supports wildcards for batch compression of multiple images (pngquant *.png). You can also use | pipes.

Compression[edit]

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:

Computer Graphics
File Original PNG image PNG, after pngquant JPG WebP
01.png 744K 216K 264K 72K
02.png 1.4M 344K 336K 92K
03.png 552K 140K 148K 44K
04.png 860K 224K 224K 60K
05.png 184K 44K 112K 36K

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 pngquant produces.

When To Use pngquant And When To Not Bother[edit]

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.

Using 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. 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.

Library[edit]

pngquant is available as a small C library called libimagequant. It is available from pngquant.org/lib under either the GNU GPL v3

Links[edit]

pngquant has a homepage at pngquant.org.


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.