в моем приложении я хочу читать метаданные изображения из ImagePickerController.Я попытался это так:
NSURL* imgURL = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];
NSLog(@"%@", imgURL);
CGImageSourceRef mySourceRef = CGImageSourceCreateWithURL((__bridge CFURLRef)imgURL, NULL);
NSDictionary *myMetadata = (__bridge NSDictionary *) CGImageSourceCopyPropertiesAtIndex(mySourceRef,0,NULL);
NSDictionary *exifDic = [myMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary];
NSDictionary *tiffDic = [myMetadata objectForKey:(NSString *)kCGImagePropertyTIFFDictionary];
NSLog(@"exifDic properties: %@", myMetadata); //all data
float rawShutterSpeed = [[exifDic objectForKey:(NSString *)kCGImagePropertyExifExposureTime] floatValue];
int decShutterSpeed = (1 / rawShutterSpeed);
NSLog(@"Camera %@",[tiffDic objectForKey:(NSString *)kCGImagePropertyTIFFModel]);
NSLog(@"Focal Length %@mm",[exifDic objectForKey:(NSString *)kCGImagePropertyExifFocalLength]);
NSLog(@"Shutter Speed %@", [NSString stringWithFormat:@"1/%d", decShutterSpeed]);
NSLog(@"Aperture f/%@",[exifDic objectForKey:(NSString *)kCGImagePropertyExifFNumber]);
NSNumber *ExifISOSpeed = [[exifDic objectForKey:(NSString*)kCGImagePropertyExifISOSpeedRatings] objectAtIndex:0];
NSLog(@"ISO %i",[ExifISOSpeed integerValue]);
NSLog(@"Taken %@",[exifDic objectForKey:(NSString*)kCGImagePropertyExifDateTimeDigitized]);
Но я получаю ошибку ImageIO:
ImageIO: CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource не удалось с кодом ошибки -11.
Я не нашел документацию о коде ошибки -11, только о -15 (плохой параметр).Я надеюсь, что у вас будет решение.
Приветсвует s4lfish