The problem is that since iOS 4 UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
strips the geolocation out. To solve this problem you have to use the original photo path to get access to the full image metadata. With something like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *rep = [asset defaultRepresentation];
NSDictionary *metadata = rep.metadata;
NSLog(@"%@", metadata);
CGImageRef iref = [rep fullScreenImage] ;
if (iref) {
self.imageView.image = [UIImage imageWithCGImage:iref];
}
} failureBlock:^(NSError *error) {
// error handling
}];
The output should be something like:
{
ColorModel = RGB;
DPIHeight = 72;
DPIWidth = 72;
Depth = 8;
Orientation = 6;
PixelHeight = 1936;
PixelWidth = 2592;
"{Exif}" = {
ApertureValue = "2.970854";
BrightnessValue = "1.115874";
ColorSpace = 1;
ComponentsConfiguration = (
0,
0,
0,
1
);
DateTimeDigitized = "2012:07:14 21:55:05";
DateTimeOriginal = "2012:07:14 21:55:05";
ExifVersion = (
2,
2,
1
);
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666667";
FNumber = "2.8";
Flash = 24;
FlashPixVersion = (
1,
0
);
FocalLength = "3.85";
ISOSpeedRatings = (
200
);
MeteringMode = 5;
PixelXDimension = 2592;
PixelYDimension = 1936;
SceneCaptureType = 0;
SensingMethod = 2;
Sharpness = 2;
ShutterSpeedValue = "3.9112";
SubjectArea = (
1295,
967,
699,
696
);
WhiteBalance = 0;
};
"{GPS}" = {
Altitude = "1167.528";
AltitudeRef = 0;
ImgDirection = "278.8303";
ImgDirectionRef = T;
Latitude = "15.8235";
LatitudeRef = S;
Longitude = "47.99416666666666";
LongitudeRef = W;
TimeStamp = "00:55:04.59";
};
"{TIFF}" = {
DateTime = "2012:07:14 21:55:05";
Make = Apple;
Model = "iPhone 4";
Orientation = 6;
ResolutionUnit = 2;
Software = "5.1.1";
XResolution = 72;
YResolution = 72;
"_YCbCrPositioning" = 1;
};
}