Sunday, January 16, 2011

iPhone Exif Data

So you want to get to some of that sweet EXIF metadata that iOS now has available? Well I did and I ran into a bit of problem but once I figured it out I had to put it here. Ok lets get down to it.

I am using - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info to return a image taken from the camera inside my app and I wanted to get at the creation date for the image DateTimeOriginal. I kept getting a null value when I attempted to extract it but it turns out I was just using the wrong key. So here is how you extract it:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSDictionary *metaData = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
NSLog("Date: %@", [[metaData objectForKey:@"{Exif}"] objectForKey:@"DateTimeOriginal"]);
}


Well thats it! I kept trying to use the key Exit but that is not it. You use {Exif} for the key...

1 comment: