Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: how to reduce size of large PNG files

I'm currently optimizing my iOS app for the new iPad. Unfortunately by adding launch images for the iPad retina display the size of my ipa grows from 1.2MB to 5.5MB, mainly because of the two PNG images in 1536 x 2008 (portrait) and 2048 x 1496 (landscape). The size of these images are respectivly 1.9MB and 1.7MB.

The portrait can be seen here: http://uploads.demaweb.dk/iPadPortrait.png.

As you may notice, the background is a fixed pattern but sadly it seems that this is not very compressible. I've further tried to compress the images using ImageOptim, but it does not make any difference after Xcode has compressed the images during the archive. Searching the web I've noticed, that some people are dissuading to turn off PNG compressing in Xcode.

Are there anything I can do? It is not a solution to change the pattern in the image to a solid color, as it should look like the background in my iOS view. But it seems odd, that supporting the new iPad increase the size by ~4MB.

like image 805
dhrm Avatar asked Mar 08 '12 19:03

dhrm


3 Answers

I was able to get it down to 633KB with pngquant (64 colors with slight dithering, which is barely noticeable on regular screen, and should be absolutely invisible at Retina resolution) and ImageOptim.

Yes, you will need to disable Xcode's conversion to avoid Xcode inflating files by converting them to ARGB.

NB: the article quoted in the accepted answer provides no benchmarks at all for the claimed speed difference.
It also contains correction that it is possible to optimize images with ImageOptim for iOS apps.

like image 90
Kornel Avatar answered Jan 03 '23 18:01

Kornel


I'm using a great tool called ImageOptim

It incorporates a number of tools inside which crush your png files significantly (in my case it was between 25% to 50%).

One thing to remember is to disable Xcode's PNG optimization (as explained on the website)

EDIT: Simply drag the images to the imageOptim window and the optimization will start automatically

like image 37
IncrediApp Avatar answered Jan 03 '23 16:01

IncrediApp


Ive struggled with this too, unfortunately not much can be done.

In an effort to dramatically increase drawing performance of iOS apps, Xcode re-compresses PNG files as it builds. It premultiplies the alpha channel and byte swaps the red, green and blue channels to be sequenced blue, green and red. The result is optimised for iOS’s purpose, but as a side effect, ImageOptim’s work gets undone…

Source

like image 24
atrljoe Avatar answered Jan 03 '23 18:01

atrljoe