pngquant vs pngcrush vs optipng vs pngnq Tue 14 January 2014

A couple of days ago I saw pngquant appear on Hacker News. I’d never really looked in depth into image compression, and after reading up on the subject I scanned through the comments on HN, discovering a number of alternative png (and other formats) optimisers. So I decided to benchmark/compare pngquant, pngcrush, optipng and pngnq.

Setup

Images: I tested a number of different images, some of which you’d be insane to render in PNG and more that make sense. The images vary greatly in size, colors and alpha channels and should be a good test for each of the optimisers. To ensure a fair test I opened & exported all the images with Photoshop, to give them all a consistent encoding algorithm.

Optimisers: I used the latest stable copy of each: pngquant 2.0.1, pngcrush 1.7.70, optipng 0.7.4 and pngnq 1.1.

Commands:

pngquant --speed 1 *.png
pngcrush <name>.png ../after/pngcrush/<name>.png
optipng -keep -o7 *.png
pngnq -d ../after/pngnq/ -s 1 *.png

Results

The raw results & images can be downloaded here.

I put together the result in a Google Docs spreadsheet which shows the sizes per-image before and after each optimiser as well as the reduction percentage. I also gave the image a quality rating (in comparison to the before image) on a scale of 1-10, where 10 is pixel for pixel perfect. Bear in mind this is only as accurate as my eyes, you should take a look at the images to decide for yourself. The highlights:

Conclusion

The results can be split in to two groups; one in which images lose almost no quality but space savings are minor and another where the quality is sacrificed in favour of significantly higher space savings. There is a clear winner here though, I will definitely use pngquant as my go-to optimiser, as it offers fantastic size reduction while keeping an acceptable/good level of quality.