我正在构建一个可以在照片过滤后添加/修改/编辑exif的应用程序。添加过滤器后照片错过了所有exif。我尝试使用下面的代码尝试将新的exif添加到照片中,这是行不通的。在Mac App中,exif仍然空白 - 照片。怎么解决? THX
//以下代码
imageData = UIImageJPEGRepresentation(outp, 1.0)
let imageSource = CGImageSourceCreateWithData(imageData! as CFData, nil)
let filePath = NSTemporaryDirectory().appending("example.jpg")
let fileURL = URL.init(fileURLWithPath: filePath)
var imageInfo = CGImageSourceCopyPropertiesAtIndex(imageSource!, 0, nil) as! Dictionary<CFString, Any>
var exifDictionay = Dictionary<CFString, Any>()
exifDictionay = imageInfo[kCGImagePropertyExifDictionary] as! Dictionary<CFString, Any>
exifDictionay[kCGImagePropertyExifExposureTime] = "1/3"
exifDictionay[kCGImagePropertyExifISOSpeed] = "200"
exifDictionay[kCGImagePropertyExifFNumber] = "2.4"
exifDictionay[kCGImagePropertyExifApertureValue] = "3.5"
exifDictionay[kCGImagePropertyExifFlash] = "On"
imageInfo[kCGImagePropertyExifDictionary] = exifDictionay
let UTI = CGImageSourceGetType(imageSource!)
let newImageData = NSMutableData()
CGImageDestinationAddImageFromSource(destination!, imageSource!, 0, imageInfo as CFDictionary)
CGImageDestinationFinalize(destination!)
PHPhotoLibrary.shared().performChanges({
let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: PHAssetResourceType.photo, data: newImageData as Data, options: nil)
}, completionHandler: nil)