Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch optimization of PNGs for iphone/ipad display as xcode does

Tags:

ios

iphone

png

ipad

I'm working on a magazine viewer for ipad and I'm struggling with the performance.

I figured out that the most expensive part of displaying the pngs is the loading process. I know that xcode is able to optimize pngs during the build and such images are loaded much faster. But I can't include all images in to the build as it will be huge.

Do you know how to optimize an arbitrary png without including it in the build process?

Do you know what is the best format for iphone? I think that pngs should use RGB-8888 color scheme but I'm not sure what else is important.

Maybe you know exact params for imagemagick?

like image 930
Piotr Czapla Avatar asked Jan 03 '11 12:01

Piotr Czapla


3 Answers

I think I've found a good article about png optimization for iphone: http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html

It seams that xcode uses this command: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize

It appears that the above command uses a modified version of pngcrush to optimize pngs and transform the color channels: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -iphone -f 0 orig.png optimized.png

And the optimization is really helpful. I've got 5 time faster image loading!

like image 52
Piotr Czapla Avatar answered Oct 21 '22 09:10

Piotr Czapla


The best results I know of are achieved with ImageOptim, which I use myself for PNGs that are not deployed via Xcode. It uses pngcrush and some other PNG optimization tools to achieve best compression. As far as I know, it doesn't employ alpha premultiplication and byte swapping though. ImageOptim also has a nice GUI with drag-and-drop support and can crush multiple files simultaneously.

like image 42
MrMage Avatar answered Oct 21 '22 09:10

MrMage


We used Pngcrush to compress huge number of PNGs. You can try this too. And also if you don't need transparency then instead of PNG you can try JPG too. But you may go through a number of trial-and-error process for this, comparing the size and quality trade-off many times.

like image 33
taskinoor Avatar answered Oct 21 '22 11:10

taskinoor