tags:

views:

67

answers:

2

Hi,

I have a large number of image files in my iphone app bundle (~3000) and I want to determine the dimensions at runtime rather than store this data in the database or an xml manifest for the images.

Is there a way to do this programatically?

A: 

UIImage has the size property that returns the dimensions of the image, however I wouldn't recommend loading all 3000 of your images in your iPhone app. Pre-generating that information at build time would give you much better results. Failing that you might possibly use some sort of naming convention for your images that encodes the image size in the file name, however this is really not that different to storing the information in some sort of database or XML file ;)

Daniel
A: 

The file Unix utility uses the header information on the file to determine the size. It basically requires loading in the first block of the file and sifting through the information (varies by file type but presumably you'll only have one to implement since you control the images).

Epsilon Prime