SwiftExif was written to facilitate porting the Munin image gallery generator to run on both Linux and macOS (it previously required ImageIO/CoreGraphics).
On Ubuntu/Debian based Linux:
apt install -y libiptc-data libexif-dev libiptcdata0-dev
On macOS using brew:
brew install libexif libiptcdata
Add SwiftExif to your dependencies:
dependencies: [ .package(url: "https://github.com/kradalby/SwiftExif.git", from: "0.0.x"), ]
SwiftExif aims to provide some simple helper functions that essentially returns all the data as dictionaries.
import SwiftExif // Read a JPEG file and return an Image object // Note: current error behaviour is to return empty dictionaries, no error is thrown. let exifImage = SwiftExif.Image(imagePath: fileURL) // Get a [String : [String : String]] dictionary. The first dictionary has items // from the spec e.g. 0, 1, EXIF, GPS... // The values are returned in "human readable format". let exifDict = exifImage.Exif() // Get a [String : [String : String]] dictionary. The first dictionary has items // from the spec e.g. 0, 1, EXIF, GPS... // The values are returned in a "raw" format. let exifRawDict = exifImage.ExifRaw() // Get a [String : Any] dictionary. // Most items are String, however "Keywords" are [String] let iptcDict = exifImage.Iptc()
In addition to the high-level functions, a set of lower-level functions is available in the different classes. Have a look at the code or the unit tests to see what else you can do.
|Last commit: 1 week ago|