tags:

views:

99

answers:

3

I have an app that will display a bunch of images in a slideshow. Those images will be part of the bundle, thus distributed with the app.

All the images are photographs or photographic, etc.

I've read that it's preferred to use PNG as the image format, but seeing that the JPG version will be much smaller, I'd rather be using that.

Are there any guidelines which format to use and in which case?

+1  A: 

I think if you want to use transparent, you have no choice except PNG. But, if your background is white already, then you may use JPG. That is the only difference I can see

vodkhang
+9  A: 

PNG's are pixel perfect (non-lossy), and require very little extra CPU energy to display.

JPG's are smaller to store, but lossy (amount depends on compression level), and to display them requires a much more complicated decoding process. But the typical compression and image quality is usually quite sufficient for photos.

Use JPG's for photos and for anything large, and PNG's for anything small and/or designed to be displayed "pixel perfect" (e.g. small icons) or as a part of a composited transparent overlay, etc.

hotpaw2
+1. Also, PNGs support transparency, which JPEGs don't.
Cameron
I've yet to see any data on JPEG vs PNG vs iPNG decode performance. Sometimes the more-compressed format is better due to reduced I/O required; I'm not sure how fast the iPhone's flash drive is. And I *definitely* wouldn't say PNG decompression requires "very little" energy; the Other.artwork file appears to be raw bitmap data, presumably because the CPU/memory overhead of PNG decompression is too much for commonly-used UI components.
tc.
+6  A: 

Apple optimizes PNG images that are included in your iPhone app bundle. In fact, the iPhone uses a special encoding in which the color bytes are optimized for the hardware. XCode handles this special encoding for you when you build your project. So, you do see additional benefits to using PNG's on an iPhone other than their size consideration. For this reason it is definitely recommended to use PNG's for any images that appear as part of the interface (in a table view, labels, etc).

As for displaying a full screen image such as a photograph you may still reap benefits with PNG's since they are non-lossy and the visual quality should be better than a JPG not to mention resource usage with decoding the image. You may need to decrease the quality of your JPG's in order to see a real benefit in file size but then you are displaying non-optimal images.

File size is certainly a factor but there are other considerations at play as well when choosing an image format.

shanezilla