3

Possible Duplicate:
When to use PNG or JPG in iPhone development?

I want to know why all suggest to use .png images instead of.jpg and .gif images for iphone applications. What is the problem when we use .gif or .jpg images. Is Apple doesn't support applications using non .png images. Please clarify me .

Thanks in advance

Community
  • 1
  • 1
praveena
  • 733
  • 2
  • 11
  • 22
  • Please check this answer: http://stackoverflow.com/questions/2336522/png-vs-gif-vs-jpeg/2336546#2336546 (just ignore notes regarding IE6 compatibility) – Anton Strogonoff Jul 14 '11 at 14:55

3 Answers3

5

The iPhone is specifically optimized to handle PNG images very efficiently. It doesn't have the same optimizations for GIF and JPEG.

In addition, if you add a PNG file as part of your XCode project, then XCode will convert the PNG file into an Apple specific variant of PNG. There seems to be no official documentation about the format, but it is said to differ from the official PNG format in byte-swapping (BGR instead of RGB) and pre-multiplied alpha channels. These changes further reduce the amount of work the iPhone has to do at run-time.

Codo
  • 75,595
  • 17
  • 168
  • 206
  • 1
    I've benchmarked this, and [Xcode conversion made files *slower* to load](http://imageoptim.com/tweetbot.html). – Kornel Mar 19 '12 at 10:39
  • Often leads to bloated PNGs as well. I can't recommend PNGYU or ImageOptim enough, (turn off PNG compression in Xcode's project build settings though!), and you'll see your PNG sizes cut in half. – CBanga Nov 26 '13 at 04:46
2

Presumably because it supports an alpha channel for transparency, nicer for UI work.

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
2

.jpg is lossy compression and so has a different purpose than .gif and .png, which are lossless.

.png files support more colors than .gif and can be smaller, depending on the image. .gif used to be patent-encumbered but AFAIK those patents have expired.

.jpg is appropriate for larger images that need more compression than a lossless format can provide, especially real photos where artifacts of lossy compression will be less obvious. If the image is small or based on vector graphics where compression artifacts are obvious, lossless is preferred.

antlersoft
  • 14,636
  • 4
  • 35
  • 55
  • Also because .png has real alpha channel, as Paul Dixon's answer. – antlersoft Jul 14 '11 at 14:55
  • 1
    I have a confession to make: I just had to google "AFAIK"... maybe I'm getting old, or maybe there are just too damn many acronyms out there. – MiguelB Jul 14 '11 at 15:16