Created
August 3, 2012 03:21
-
-
Save hisasann/3244029 to your computer and use it in GitHub Desktop.
UIImagePickerControllerでイメージピッカーからExif情報を抜き出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { | |
NSLog(@"imagePickerController - %@", image.description); | |
UIImage *editedImage = [editingInfo objectForKey:UIImagePickerControllerEditedImage]; | |
UIImage *originalImage = [editingInfo objectForKey:UIImagePickerControllerOriginalImage]; | |
__weak CameraViewController *__self = self; | |
NSURL *assetURL = [editingInfo objectForKey:UIImagePickerControllerReferenceURL]; | |
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
[library assetForURL:assetURL | |
resultBlock:^(ALAsset *asset) { | |
ALAssetRepresentation *representation = [asset defaultRepresentation]; | |
NSDictionary *metadataDict = [representation metadata]; // ←ここにExifとかGPSの情報が入ってる | |
__self.exif = [metadataDict objectForKey:@"{Exif}"]; | |
// イメージピッカーを隠す | |
[__self dismissModalViewControllerAnimated:NO]; | |
// ここでプレビュー画面を開く | |
[__self showCameraConfirmView:image isAlbum:YES exif:__self.exif]; | |
NSLog(@"[metadataDict objectForKey:@\"Exif\"] - %@", [metadataDict objectForKey:@"{Exif}"]); | |
} failureBlock:^(NSError *error) { | |
NSLog(@"ALAssetsLibrary error - %@", error); | |
// エラーの場合はExifは無視する | |
__self.exif = nil; | |
// イメージピッカーを隠す | |
[__self dismissModalViewControllerAnimated:NO]; | |
// ここでプレビュー画面を開く | |
[__self showCameraConfirmView:originalImage isAlbum:YES exif:__self.exif]; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment