Not All PNG Compressors Are Created Equal
Posted on Thursday September 15, 2011 by Randall Brown
Not All PNG Compressors Are Created Equal
Don't believe me? Here's two versions of a Jing logo from one of our press releases.

So what's the difference? The image on the right is less than 1/2 the size of the original image on the left. If the PNG compressor doesn't optimize color depth, or uses non-aggressive DEFLATE compression it can produce PNG's that are up to 90% bloat.
Not just for the web
Optimizing the PNG's in the Camtasia Relay PC recorder resulted in a ~7% (302KB) file-size reduction."302KB... big-whoop, people have big hard drives now-a-days"
Touché. But know that file size isn't the only thing affected. With optimized PNG's, the Relay recorder's memory usage decreased ~6.5% (23,736KB vs. 25,268KB) and the start-up time decreased by ~5% (0.774 vs. 0.811 sec avg over 20 iterations). Keep in mind that the Relay recorders are relatively small apps and use a relatively small number of PNG's. Other, larger, applications may see more drastic results.
Producing optimized PNG's
In the case of the Jing logo, it looks like Photoshop is the culprit. When using Photoshop, always use "Save for Web & Devices..." rather than "Save As..." for the final image.
If you've already got a bunch of un-optimized PNG's, utilities like PNG Gauntlet help batch process them.
The sprite sheet dilemma
Why did relay.sprite.3.1.png only get a 6% improvement while others got 70-80% improvements? Unfortunately, if even 1 out of 100 images requires 32bit color, the entire sprite sheet is required to use 32bit color. Thus, color depth optimizations are impossible in this case :-( . However, this does not mean that you should immediately slice up all your sprites. Sprites are still awesome at reducing file size and network requests. But, combining all images with varying color depths into a single sprite sheet might not be size-optimal.


Comments (1)
Excellent article, thanks for sharing. I suppose I should go and convert some old PNGs now...
Posted by Anton Bollen | September 20, 2011 11:24 AM
Posted on September 20, 2011 11:24