Optimize PNG images with OptiPNG

by Stephen Fluin 2011.08.17

PNG is a great free lossless, compressed image format. One thing that may surprise you is that PNGs can actually be further compressed, making the filesize smaller than a normal image application will typically achieve. The good news is there there is a tool called optipng that makes it easy to non-destructively improve the layout of PNG files.

On Ubuntu, install OptiPNG with sudo apt-get install optipng. Once it is installed, you can run it its default mode by typing optipng file.png. If you feel like giving the application lots of time to achieve aggressive compression, you can use the -o flag to indicate additional compression. Compared between the default and -o7, I have found only minimal additional compression that has almost never been worth the additional CPU time.

Below are the results of one such compression attempt:

optipng -o7 fresh-new-tab-window.png OptiPNG 0.6.4: Advanced PNG optimizer. Copyright (C) 2001-2010 Cosmin Truta. ** Processing: fresh-new-tab-window.png 1358x640 pixels, 4x8 bits/pixel, RGB+alpha Input IDAT size = 436116 bytes Input file size = 436853 bytes Trying: zc = 9 zm = 8 zs = 1 f = 5 IDAT size = 436116 Output IDAT size = 436116 bytes (no change) Output file size = 436217 bytes (636 bytes = 0.15% decrease)