Unable To View iOS App PNG Files? Undo Xcode PNG Optimizations Using pngcrush

PNG images that you include within an Xcode project are optimzed during the application build process. Good news is, this often results in a smaller application bundle. Bad news is, the resulting PNG images typically cannot be opened in Preview or other imaging software.

The tool doing the optimization is pngcrush, an open source utility available on SourceForge.

Undo pngcrush Optimizations

If you have iPhone SDK 3.2 or greater installed (and did not change the default install path), pngcrush is located here: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush

If you would like view or otherwise open PNG files within an Xcode build (.app file), you will need to revert the optimizations on the file, the command line syntax for this is shown below:

-revert-iphone-optimizations -q OptimizedPNG.png RevertedPNG.png

OptimizedFile.png is the name of the optimized PNG inside the .app bundle, RevertedPNG.png is the file output by pngcrush after the optimizations are removed.

  1. A couple of vaguely related questions come to mind:

    Does the size optimization typically result in slower decompression in the application?

    For any given compressed image (.png, .jpg, etc.), how often does the application have to decompress it? I know that UIImage objects are cached once accessed with imageWithName: — is it safe to assume that the image is decompressed at the time the object is created and then kept uncompressed? I could easily imagine that the memory manager might delete uncompressed UIImage data as a first step when memory starts getting tight, possibly even before sending didReceiveMemoryWarning messages to the app.

Comments are closed.