I need to get the GPS coordinates of an image taken with the iOS device\'s camera. I do not care about the Camera Roll images, just the image taken with UIImagePickerControl
One possibility is to leaving CoreLocation running when the camera is visible. Record each CCLocation into an array along with the time of the sample. When the photo comes back, find its time, then match the closest CClocation from the array.
Sounds kludgy but it will work.
This is tested on iOS 8 and works for videos so it should work similarly for photos with a few tweaks.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *videoUrl = (NSURL *)[info objectForKey:UIImagePickerControllerMediaURL];
NSString *moviePath = [videoUrl path];
if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) ) {
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset) {
CLLocation *location = [asset valueForProperty:ALAssetPropertyLocation];
NSLog(@"Location Meta: %@", location);
} failureBlock:^(NSError *error) {
NSLog(@"Video Date Error: %@", error);
}];
}
}
You're not using the image data from the camera in the code you've posted, you've generated a JPEG representation of it, which would essentially discard all the metadata. Use image.CGImage
like Caleb suggested.
Also:
This is also for a commercial product so I cannot use http://code.google.com/p/iphone-exif/.
The author quite clearly states that commercial licensing is available.