【发布时间】:2018-05-29 10:56:40
【问题描述】:
我有一张包含很多 exif informations 的图片。但是当试图用swift读取exif信息时,它显示的exif信息数量有限。
我试过以下代码:
let data = UIImageJPEGRepresentation(image, 1.0)
let source = CGImageSourceCreateWithData(data! as CFData, nil)
let metadata = (CGImageSourceCopyPropertiesAtIndex(source!, 0, nil))
debugPrint(metadata ?? "nil")
它会打印以下结果:
{
ColorModel = RGB;
Depth = 8;
Orientation = 6;
PixelHeight = 2448;
PixelWidth = 3264;
ProfileName = "sRGB IEC61966-2.1";
"{Exif}" = {
ColorSpace = 1;
PixelXDimension = 3264;
PixelYDimension = 2448;
};
"{JFIF}" = {
DensityUnit = 0;
JFIFVersion = (
1,
0,
1
);
XDensity = 72;
YDensity = 72;
};
"{TIFF}" = {
Orientation = 6;
};
}
如何从 UIImage 中读取所有 exif 信息?
【问题讨论】:
-
你能检查一下我附在那儿的图片吗?有我试图访问的所有图像信息。我的问题是为什么它没有打印所有的 exif 信息。
-
我无法给你一个好的答案,但我所看到的表明它可能不是你的代码提取的一部分。我只是使用
UIImagePickerController相机和UIImagePickerControllerMediaMetadata来查看所有EXIF 数据并保存图像。但后来我在所述图像上使用了你的代码(这也是我会做的),发现CGImageSourceCopyPropertiesAtIndex只有你发现的 - 一个不完整的数据字典。 -
仅供参考,这些无济于事,但它们是我保存的关于 Swift 和 EXIF 的其他问题:stackoverflow.com/questions/43920643/modifying-image-metadatastackoverflow.com/questions/37992611/…stackoverflow.com/questions/40175160/exif-data-read-and-write
标签: ios swift uiimage core-image