When to use PNG or JPG in iPhone development?

Maverick picture Maverick · Oct 14, 2010 · Viewed 45k times · Source

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?

Answer

hotpaw2 picture hotpaw2 · Oct 14, 2010

PNG's are pixel perfect (non-lossy), and require very little extra CPU energy to display. However, large PNGs may take longer to read from storage than more compressed image formats, and thus be slower 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 algorithm. 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.