Bjango home
Articles
Help
Contact
iStat Menus
iStat for iOS
Consume for iOS
Skala
Skala Preview
iStat Server
for Mac
See all apps

PNG compression and iOS apps

If you’re spending a lot of effort compressing or optimising your PNG images for iOS app development, you’re probably wasting your time.

At face value, running your images through a tool like ImageOptim seems like a great idea. It grinds away, shaving kilobytes or bytes off each file, hopefully helping your app download and launch faster. Very good things to aspire to, and well worth some consideration and effort.

Enter Xcode. In an effort to dramatically increase drawing performance of iOS apps, Xcode re-compresses PNG files as it builds. It premultiplies the alpha channel and byte swaps the red, green and blue channels to be sequenced blue, green and red. The result is optimised for iOS’s purpose, but as a side effect, ImageOptim’s work gets undone, due to the images being rebuilt (please read Jeff Lamarche’s article on the topic for more technical info on exactly what Xcode does).

To get some real world results, I saved seven files from a recent project using Photoshop’s Save As and Save For Web, and also ran the Save For Web image set through ImageOptim once and twice (sometimes a second run through ImageOptim’s processing can increase the benefit). The images were chosen for various qualities — some were small icons with transparent backgrounds, some were large opaque Retina images. I wasn’t particularly scientific about it, but a good range was covered.

Each bar graph below shows the total size of the six images in bytes. The different methods yield different results, and ImageOptim certainly helps knock a few more bytes off.

The Index image set was created using Save For Web with the PNG-8 format, so they’re only 256 colour (not recommended). I included these just to see if Xcode processed PNG-8 files as well as PNG-24 (full colour PNGs, that are far more typical in iOS development).

Default@2x NT is a duplicate of Default@2x, but with the Transparency option turned off in Photoshop’s Save For Web dialogue.

So far, the results vary wildly, with ImageOptim’s output the clear winner.

The story is quite different after Xcode has had its way with the images.

Two of the ImageOptim images had ever-so-slightly smaller file sizes. I’d love to know why, but the difference was so small that I’m not sure it warrants further investigation.

All tests were conducted using ImageOptim 1.2.5, Photoshop CS5 and Xcode 4.2.1. ImageOptim combines a bunch of PNG optimisation tools, like OptiPNG, PNGCrush, AdvPNG and PNGOUT.

It is possible to disable Xcode’s PNG compression, but you’d want to have a very good reason for doing so. One reason may be that your specific use case requires smaller files over optimised drawing. The ImageOptim website has instructions on how to do it.

If you’re willing to invest a little time, it’s even possible to use AdvPNG to create iOS-specific PNG images.

There’s definitely some good tools and good reasons to optimise your images for the web, but I wouldn’t bother for most iOS app development.

Other articles

App Store description previewer
My app design workflow
Gradient maps
Strokes in Photoshop CS6
Just like print design
Layer tags
Using algebra to create paths
Sub-pixel text rendering
Photoshop Actions & Workflows
Scale Patterns to 100% script
Text in Photoshop CS6
Masking in Photoshop CS6
Illustrator and app design
Vector shapes in Photoshop CS6
Photoshop CS6 improvements
Pixels per inch is just a tag
PNG compression and iOS apps
Everything is a grid
Smart Objects
Exporting from Photoshop
Iterate Podcast
Pixel perfect rotation
Pixel perfect vector pasting
Pixel perfect vector nudging
What if iChat was one window?
Gradients
Designing for Retina display
Designing for Retina display, part two
A new Drobo Dashboard icon
Noise and textures
Photoshop CS6 wish list
What to do with all those extra pixels?
Photoshop roundrect roundup
Colour management and UI design
How many layers are in my PSD?
Dissecting iTunes and App Store links

About the author

Marc Edwards is the Director & Lead Designer at Bjango. Follow @marcedwards on Twitter and @marc on App.net.

  • Bjango on Twitter
  • Bjango on Dribbble
  • Bjango on GitHub
  • Bjango on App.net
  • RSS Feeds
  • Marc on App.net

©2013 Bjango Pty Ltd. All rights reserved. ABN 88 062 334 580.
Apple, the Apple logo, iPad, iPhone, and iPod touch are trademarks of Apple Inc., registered in the U.S. and other countries. App Store is a service mark of Apple Inc.
Please fasten safety harness before continuing.