【发布时间】:2019-12-21 12:16:25
【问题描述】:
我目前正在尝试使用其他自定义元数据(例如热温度统计等)保存 UIImage 的 jpeg 表示。这些不适合苹果预定义的键 (https://developer.apple.com/documentation/imageio/cgimageproperties),因此我找到的解决方案不适用于我的场景。
我尝试将元数据与图像一起保存为键和值的字典,但图像在保存时没有附加元数据。
func saveImage(imageToSave: UIImage, metadata: NSMutableDictionary) {
if let data: Data = imageToSave.jpegData(compressionQuality: ThermalImageView.JPEG_COMPRESSION) {
let fileName = self.buildFileName();
let source = CGImageSourceCreateWithData(data as CFData, nil)!;
let uniformTypeIdentifier = CGImageSourceGetType(source)!;
let destination = CGImageDestinationCreateWithURL(fileName as CFURL, uniformTypeIdentifier, 1, nil)!;
CGImageDestinationAddImageFromSource(destination, source, 0, metadata);
CGImageDestinationFinalize(destination);
}
}
当我尝试使用 ExifTool (exiftool -j filename.jpg) 读取这些值时,找不到元数据。我预计会发生这种情况,因为 Apple 似乎限制了您可以添加到元数据中的密钥。那么,有没有办法做到这一点,还是我应该走另一条路?
谢谢!
编辑:我想我可能在这里叫错了树。看来我真正想做的是用额外的元数据修改标题。
【问题讨论】: