Question

I have to link a date and a name to some jpegs that I am including in my bundle, or possibly downloading from my own server to the Documents folder. Is there a way to extract EXIF data easily?

If so, then I will use EXIF to store this info. If not, then I will have to create a database or flat file that maps my extra data to the image file.

Keep in mind, these are not photos the iPhone has taken and is providing via UIImagePicker or from outside the sandbox. These are photos that I am including with the app or downloadig to the Docs folder myself. The important point here is ease:

Is it easier to

  • read EXIF file from my image files
  • have another file that keeps track of the image file and the associated data (could be sqlite)

Thanks!

Was it helpful?

Solution

You can try using iphone-exif toolkit to extract the data. However, it's licensed GPL and if your app is commercial you'll need to negotiate a license deal. If that's not viable then you may want to go the external meta-data route.

OTHER TIPS

The actual EXIF data is stored in the form of a small TIFF file with EXIF-specific TIFF tags for information that doesn't have a home in the TIFF specification. When placed in a JPEG file (really a JFIF bitstream), it is stored in a JPEG APP1 marker which limits the total size of the EXIF data to just a bit less than 64KB.

It shouldn't be that difficult to locate the APP1 marker, confirm it contains EXIF data, and then parse out a specific collection of EXIF tags with fairly brute force coding.

One example you can look at is exiftool which does just that, and is written in Perl and open source under the same terms as Perl itself.

If these files are purely for use in your own application and will not be reused in other tools by the user, then there is some mileage in storing your data as XML/JSON in the comment segment 0xFFFE. As mentioned before you get just short of 64k to play with.

The beauty of using the comment segment is that it should be preserved by image editing tools, is quick to access (because you do not need to traverse the IFD blocks that store EXIF data, you just read/write a text string with 4 byte type/length header) and is human readable/writable in a graphics app.

I would avoid storing the associated data in a db if practical, so that you don't risk the db becoming out of sync with the available files.

I use ExifTool

embedded in my app. Works a treat.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top