开发者

Get GPS data from camera photo metadata

I get a photo for my app with help of UIImagePickerController. Is it possi开发者_JAVA技巧ble 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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜