我正在使用requestImageDataForAsset来获取图像的完整数据,然后使用ImageIO来提取其exif信息。但是,似乎我没有获得图像的完整元数据,这里有没有人有类似的问题?
这是我的代码
//Code to fetch PhotoAsset
...
PHImageManager.defaultManager().requestImageDataForAsset(self.selectedPhotoAsset, options: options) {
photoData, photoUTI, photoOrientation, photoInfo in
self.selectedPhotoData = photoData
self.fetchPhotoMetadata()
}
func fetchPhotoMetadata() {
let selectedImageSourceRef = CGImageSourceCreateWithData(self.selectedPhotoData as CFData, nil) as CGImageSourceRef
let imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(selectedImageSourceRef, 0, nil) as NSDictionary
for (key, value) in imagePropertiesDictionary {
println("Key: \(key) Value: \(value)")
}
}
元数据的输出:
Key: {TIFF} Value: {
ResolutionUnit = 2;
XResolution = 72;
YResolution = 72;
}
Key: DPIWidth Value: 72
Key: DPIHeight Value: 72
Key: ColorModel Value: RGB
Key: PixelHeight Value: 768
Key: Depth Value: 8
Key: {Exif} Value: {
ColorSpace = 1;
ComponentsConfiguration = (
1,
2,
3,
0
);
ExifVersion = (
2,
2,
1
);
FlashPixVersion = (
1,
0
);
PixelXDimension = 1024;
PixelYDimension = 768;
SceneCaptureType = 0;
}
Key: PixelWidth Value: 1024