I’ve always been interested in app file size and the overall app’s performance. When dealing with images, these sometimes go hand in hand…
To make my images smaller and more efficient to load, I use a tool called ImageOptim. This removes all the bloated metadata from your image and also tries different techniques to make the file size as small as possible. Note that Xcode also has it’s own PNG compression settings, which are supposed to make it more efficient in opening Xcode compressed PNG files at runtime.
ImageOptim claims that because their image sizes are much smaller than Xcode’s, or Photoshop’s, the time taken to load an image is much quicker, regardless of how much better the other formats are.
There seems to be a lot of tests for PNGs, but not much for JPEGs or GIFs, so I set out to test these myself.
All of the images used had both a version saved from Photoshop’s “Save for web” dialog, and then another using ImageOptim.
The PNG had an additional version, which was Xcode’s compressed PNG.
The following formats were tested:
- GIF (256 colours)
- JPEG (0 quality)
- JPEG (100 quality)
- PNG (24 bit)
The times shown are inclusive of opening the file and decoding the data, so it’s ready to draw to the screen. A smaller bar is better. I’ve also included the file sizes of each image – these are also attached at the end if you want to run the same tests.
The image loaded was the following (larger than this…):
Most images on an iOS application will be PNGs so this is what I am most familiar with. The results for the PNG images were as I suspected. ImageOptim’s superior file size shined through and yielded the smallest load time. Xcode was close to Photoshop’s “Save for web”, and even though it was a little bit slower, based on the much larger file size you can tell that it does have some efficiencies.
GIF images; not surprising, considering the file sizes were nearly the same.
JPEG images did surprise me a little. Based on my tests, the ImageOptim JPEGs were slower to read, even at the smaller file size. I’m assuming that some added complexities to the file contents to get it that small also add to the decoding time.
You can download the images I used here.