【发布时间】:2021-03-13 07:34:48
【问题描述】:
我打开并编辑我的 jpg 文件中的 EXIF(或 TIFF...)数据。 请帮助我用编辑数据保存(覆盖)我的 jpg 文件。 使用这个简单的代码:
let fileURL = URL(fileURLWithPath: "/Users/test/Pictures/IMG_2808.jpg")
if let imageSource = CGImageSourceCreateWithURL(fileURL as CFURL, nil) {
var imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary?
let exifDict = imageProperties?[kCGImagePropertyExifDictionary]
if let UserComment = exifDict?[kCGImagePropertyExifUserComment] ?? nil {
print("kCGImagePropertyExifUserComment: \(UserComment)")
}
else {
exifDict!.setValue("My comment...", forKey: kCGImagePropertyExifUserComment as String)
imageProperties![kCGImagePropertyExifDictionary] = exifDict
// What I should do in the next step for update and override my jpg file on disk?
// Maybe this is not nice way for this realisation? Please help
//
}
}
【问题讨论】:
标签: swift image save jpeg exif