是否可以访问iOS中UIImagePickerController捕获的图像的元数据?我理解这可以通过AssetLibrary框架来完成相机应用程序捕获的图像(或者存在于iPhone照片库中),但是开发人员可以在用户完成之后立即访问应用程序中的任何元数据/ exif信息。图片?我正在寻找拍摄后的任何类型的相机曝光级信息。谢谢!
答案 0 :(得分:5)
显然,您可以在拍摄后立即访问图像的元数据。选择图像后系统调用的协议方法是:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
NSDictionary参数info包含一个键:UIImagePickerControllerMediaMetadata
现在,如果我能弄清楚如何从中获取exif标签或任何曝光级信息来推断关于光级的基本信息,我将很高兴。 :)
答案 1 :(得分:0)
使用照片框架更新到iOS 11
目标 - C:
#import <Photos/Photos.h>
- (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
PHAsset* asset = info[UIImagePickerControllerPHAsset];
[asset requestContentEditingInputWithOptions:nil completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
CIImage *fullImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL];
NSLog(@"%@", fullImage.properties.description);
}];
[imagePicker dismissViewControllerAnimated:YES completion:nil];
}
您还需要照片库使用权限(NSPhotoLibraryUsageDescription),然后才能添加以下代码以查看是否显示加载或视图
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
switch (status) {
case PHAuthorizationStatusAuthorized:
NSLog(@"PHAuthorizationStatusAuthorized");
break;
case PHAuthorizationStatusDenied:
NSLog(@"PHAuthorizationStatusDenied");
break;
case PHAuthorizationStatusNotDetermined:
NSLog(@"PHAuthorizationStatusNotDetermined");
break;
case PHAuthorizationStatusRestricted:
NSLog(@"PHAuthorizationStatusRestricted");
break;
}
}];