12 Comments on “UIImage+MetaData (+ iPhone camera roll) [was] still a huge problem [in iOS4.0]”

  1. Steve says:

    I am using the AVCaptureStillImageOutput to capture a still image from the camera (from the AVFoundation.framework). This block handler will receive a CMSampleBufferRef. I then use AVCaptureStillImageOutput jpegStillImageNSDataRepresentation to create a NSData representation. This method should merge any exif information and image data together (it does).

    Next I create a CGImageSourceRef and grab the dictionary out of it. The exif headers are all intact with the same information that the Camera.app stuffs into it’s pictures.

    I then use CGImageCreateWithJPEGDataProvider to create a CGImageRef. Save the file. Reaload it and parse the dictionary. The exif data is still there.

    It is the call to writeImageToSavedPhotosAlbum from the AssetLibrary.framework that is stripping the info. I suspect that it receives the CGImageRef and creates a UIImage before saving.

    • smallduck says:

      So when using CGImageCreateWithJPEGDataProvider to create a CGImageRef, how do you then save that CGImage? Is it like:
      pvdr=CGImageGetDataProvider(img);
      data=CGDataProviderCopyData(pvdr);
      ...write data to file normally...

      Things that I’ve seen had led me to believe that metadata does not go into a CGImage, but maybe it does but is just not accessible in any way I’ve seen.

    • jeeva says:

      but this method not saving GPS data even though we attached to metadata dictionary one more thing exif data is default metadata of an image.

      • smallduck says:

        I believe exif is an additional encoding of the same info that is elsewhere in the metadata dictionary. I haven’t dug deep into this topic yet. Are you saying you’re trying to add GPS to the metadata dictionary and it’s not getting saved?

        I’d too like to know why this is happening for you. Have you asked on Apple’s developer forum? I’d suggest posting a question there including relevant snippits of your code. I’ll keep and eye out for such a thread.

      • Kolya says:

        Hi,
        I’m having the same problem. Did you ever figure this one out?

      • smallduck says:

        Sorry I didn’t see your comment for, wow, several months. (I wrote an answer to probably a different question here and included link to a stackoverflow page, now added as an update to the original post above)

  2. smallduck says:

    I see this page has got some big google juice when searching for something like “iphone sdk image metadata”, so I thought it’d be smart to fix a typo in the title (duh) & and attach an update.

  3. huygir says:

    It’s still inadequate… what if you can’t use the “Camera” source type… you cannot get the EXIF from a saved photo in the library in order to upload it. Ridiculous limitation.

    For example.. on an iPad that has no camera but lots of photos copied into the library using the camera connector.

    Just how freaking hard is it to load the metadata into a property of the UIImage? Really?

  4. Kolyah says:

    Hi Smallduck,

    Thanks very much for the reply. I couldn’t work out how to reply in-line so I’m doing it here.

    Funnily enough, I wrote the the answer you link to on StackOverflow after much banging of my head against the wall. It’s a small world!

    • smallduck says:

      That’s funny. I wrote that reply not checking what it was in context to. I see now you were probably asking about adding to the metadata. Everything I know I figured out from other people’s StackOverflow posts like yours & I’m guessing you know as much or more than I do.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s