博客> 获取图片exif信息
获取图片exif信息
2017-08-16 14:58 评论:0 阅读:582 深山野猪
ios

After iOS8: @property (nonatomic, strong) PHAsset asset; [[PHImageManager defaultManager] requestImageDataForAsset:self.asset options:nil resultHandler:^(NSData imageData, NSString dataUTI, UIImageOrientation orientation, NSDictionary info) { NSDictionary *metadata = [self metadataFromImageData:imageData]; }];

-(NSDictionary)metadataFromImageData:(NSData)imageData{ CGImageSourceRef imageSource = CGImageSourceCreateWithData((bridge CFDataRef)(imageData), NULL); if (imageSource) { NSDictionary options = @{(NSString )kCGImageSourceShouldCache : [NSNumber numberWithBool:NO]}; CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (bridge CFDictionaryRef)options); if (imageProperties) { NSDictionary metadata = (__bridge NSDictionary )imageProperties; CFRelease(imageProperties); CFRelease(imageSource); return metadata; } CFRelease(imageSource); } return nil; }

Before iOS8: ALAsset *asset; self.asset.defaultRepresentation.metadata

收藏
0
sina weixin mail 回到顶部