2016-10-21 189 views
3

我搜索从图片文件中获取EXIF数据并将它们写回Swift。但我只能找到不同语言的预定库。EXIF数据读取和写入

我还发现对“CFDictionaryGetValue”的引用,但我需要哪些键来获取数据?我该怎么写回来?

+1

已经有一个'swift'标签。在问题标题中包含什么? –

+2

好的,我想表明语言很重要。我将来不会使用它。 –

+0

当然,我会尽我所能。 :-)我会看到我有多远。 –

回答

8

我使用这得到的图像文件 EXIF相关信息:

import ImageIO 

let fileURL = theURLToTheImageFile 
if let imageSource = CGImageSourceCreateWithURL(fileURL as CFURL, nil) { 
    let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) 
    if let dict = imageProperties as? [String: Any] { 
     print(dict) 
    } 
} 

它可以让你包含各种信息,如颜色配置文件的字典 - 的EXIF信息特别是dict["{Exif}"]

+1

非常感谢。那更多,我期望的! –

+0

如何将EXIF数据写回图像? – Genfood