如何在 swift 中获取磁盘上图像的颜色配置文件数据

How to get the Color Profile data for an image on disk in swift

不太明白如何以编程方式获取 swift 中任何给定照片的“更多信息”部分中的所有内容。我对颜色配置文件数据特别感兴趣。有什么想法吗?

原来很简单:

let path = // Some Image path on disk
let url = NSURL.fileURL(withPath: path)
let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil)
if imageSource != nil {
let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource!, 0, nil)
var dict = imageProperties as! Dictionary<String, Any>
print(dict["ProfileName"]!)
}