如果我们在Assets.xcassets中有图像imageName.jpg,那么让我们把这个图像放在UIImage中:
let imageForExif: UIImage = UIImage(named: "imageName.jpg")!
我们如何使用Swift从imageForExif获取(提取)Exif数据?
答案 0 :(得分:2)
试试这个......
if let imageData = UIImageJPEGRepresentation(imageForExif, 1.0) {
let imageCFData = imageData as CFData
if let cgImage = CGImageSourceCreateWithData(imageCFData, nil), let metaDict: NSDictionary = CGImageSourceCopyPropertiesAtIndex(cgImage, 0, nil) {
let exifDict: NSDictionary = metaDict.object(forKey: kCGImagePropertyExifDictionary) as! NSDictionary
print(exifDict)
}
}
但您可能拥有非常有限的数据。希望它有所帮助。