2012-04-27 20 views
0

メタデータ(IPTC)付きのアルバム写真から写真ファイルを取り出すことは可能ですか?
UIImagePickerControllerを使ってUIImageを取得しようとしましたが、ファイルに保存するときにメタデータ情報が含まれていません。
ALAssetライブラリで元の写真ファイルを取得する方法はありますか?アルバム写真のメタデータ付き写真ファイルを取得

+0

これは、メタデータhttp://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/をretriveするあなたを助けるかもしれませんUIImagePickerControllerDelegate.html#// apple_ref/doc/constant_group/Editing_Information_Keys – Bala

答えて

1

私はAssetsLibraryと解決策を見つけた:

- (void)savePhoto:(NSURL*) url <br 
{ 
    NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
    ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init]; 
    [assetLibrary assetForURL:url resultBlock:^(ALAsset *asset) { 
     NSString* originalFileName = [[asset defaultRepresentation] filename]; 
     NSString *path = [applicationDocumentsDir stringByAppendingPathComponent:originalFileName]; 
     ALAssetRepresentation *rep = [asset defaultRepresentation]; 
     Byte *buffer = (Byte*)malloc(rep.size); 
     NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil]; 
     NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES]; 
     //NSLog(@"%@",data); 
     [data writeToFile:path atomically:YES]; 
    } failureBlock:^(NSError *err) { 
     NSLog(@"Error: %@",[err localizedDescription]); 
    }]; 
} 
関連する問題