Compression utility pngout – a free lunch, bytes are on the menu

Pngout is a free command line utility for compressing png files without any loss in image quality. Pngout compresses PNG files really really well (10-30% savings is typical).  That translates into real dollars in terms of storage and bandwidth for large scale sites. Most importantly it reduces page load time.

If that doesn’t get you excited it may be helpful to know that pngout was written by a software genius (Ken Silverman, author of the Duke Nukem 3D engine). Plus it is free and available for Mac, Windows and Linux.

For more on the subject of PNG files and why pngout is great, here is a write up by Jeff Atwood: Getting the Most Out of PNG.

I use pngout as part of every release that adds or updates png graphics. Pngout squeezes down output from Photoshop, Paint.NET, or other graphics programs. After using this tool for several years I can say it has never corrupted a file or given me problems. On large files it is pretty slow (~30 seconds to process a complex 500kb sprite graphic).

Since I use it all the time, I wanted to share some helpful commands. I store pngout in a common spot. On windows: c:\software\pngout.exe, or on Mac/Linux: someplace like /usr/bin/pngout.

The nice thing about these commands is they work recursively, so just cd to the directory that contains your project and blast away. Running pngout on a file twice does not hurt it.


$ find . -name "*.png" -exec /usr/bin/pngout {} \;


$ find . -name "*.png" -exec /cygdrive/c/software/pngout {} \;

Windows (DOS prompt):

for /R %i in (*.png) do C:\software\pngout "%i" /y



Additional thoughs for using pngout:

  • I recommend building pngout into your development process. Could be any of the following:
    • Pre-check in process developers are responsible for.
    • A build step.
    • A merge to trunk step.
    • A Jira reminder for the BDFL before each release.
    • Either way pngs are automatically compressed before the feature ships. It is too easy to forget about pngout otherwise.
  • Pngout should be used before uploading PNG files to a CDN.
  • Pngout can be called on the server side after a user uploads an image. However since pngout can be slow, I would advise setting up a background job for the compression step, as opposed to making the user wait for the compression.


Pngout download page

This entry was posted in Application Development, Sys Admin and tagged , , , . Bookmark the permalink.

2 Responses to Compression utility pngout – a free lunch, bytes are on the menu