从图库中选取图像后,图像exif数据中没有日期信息。但是当我使用在线工具检查相同图像的exif数据时,它就在那里。任何人都可以告诉我从exif数据获取日期信息的解决方案。我尝试了以下代码,但它没有打印日期信息。我试过不同类型的图像。
let data = UIImageJPEGRepresentation(image, 0.5)
let source = CGImageSourceCreateWithData(data as! CFData, nil)
let metadata = CGImageSourceCopyPropertiesAtIndex(source!, 0, nil) as! NSDictionary
print(metadata )
上述代码的输出是
{
ColorModel = RGB;
Depth = 8;
Orientation = 1;
PixelHeight = 2448;
PixelWidth = 2448;
ProfileName = "sRGB IEC61966-2.1";
"{Exif}" = {
ColorSpace = 1;
PixelXDimension = 2448;
PixelYDimension = 2448;
};
"{JFIF}" = {
DensityUnit = 0;
JFIFVersion = (
1,
0,
1
);
XDensity = 72;
YDensity = 72;
};
"{TIFF}" = {
Orientation = 1;
};
}