2016-10-21 185 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