Viewing iPhone-Optimized PNG

Q: When I build my iPhone OS application, Xcode optimizes the PNG files within my application’s bundle, meaning that Preview can’t display them. How can I view these optimized files?

A: This optimization is done by the pngcrush tool, which you can find in /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush (assuming you installed the iPhone SDK in the standard place). In iPhone SDK 3.2 and later, the pngcrushtool supports a command line option, -revert-iphone-optimizations, that undoes the optimizations done during the Xcode build process. So, to view an optimized PNG file, you should first undo the optimization and then open it with Preview.

Listing 1 shows how you can use the pngcrush tool to convert an iPhone-optimized PNG file (Local.png) to a standard PNG file (Local-standard.png).

Listing 1: Undoing iPhone PNG optimization

$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush \ -revert-iphone-optimizations -q Local.png Local-standard.png

Above is the document from apple explaining how to convert the optimized png files to standard ones.

Here is a a  ruby script called appcrush that automates this process.

Original post:

Point appcrush at an .ipa file from the iTunes AppStore and it:

  • expands the zip file
  • finds all the images
  • runs pngcrush with the revert-iphone-optimizations option on each image

appcrush ‘/Users/boctor/Music/iTunes/Mobile Applications/iBooks.ipa’

You can find appcrush here: