ArisRS
ArisRS

Reputation: 1394

Get GPS data from camera photo metadata

I get a photo for my app with help of UIImagePickerController. Is it possible to get Geo data from the delegate:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

Here is info dictionary, is it possible to get Geo tags from it?

Upvotes: 0

Views: 2645

Answers (2)

Chris Markle
Chris Markle

Reputation: 2106

Up to and including iOS 5.1.1, the UIImagePickerController does not add GPS location data to photos shot using it. It doesn't matter what the setting of location services for the Camera app is, that only controls that app not the UIImagePickerController.

You will need to use the CLLocation class to get the location and then add that to any images and videos shot with the UIImagePickerController.

Upvotes: 0

Marek Sebera
Marek Sebera

Reputation: 40681

use EXIF library http://code.google.com/p/iphone-exif/

code

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    NSData* jpegData = UIImageJPEGRepresentation (image,0.5);
    EXFJpeg* jpegScanner = [[EXFJpeg alloc] init];
    [jpegScanner scanImageData: jpegData];
    EXFMetaData* exifData = jpegScanner.exifMetaData;
    EXFTag* latitudeDef = [exifData tagDefinition: [NSNumber numberWithInt:EXIF_GPSLatitude]];
    EXFTag* longitudeDef = [exifData tagDefinition: [NSNumber numberWithInt:EXIF_GPSLongitude]];
...}

SO question: UIImagePickerController and extracting EXIF data from existing photos

Upvotes: 1

Related Questions