SimpleExif
SimpleExif copied to clipboard
How to save image in document directory with EXIF Data.
How can I save image with Metadata in document directory and read it again from document directory?
I am saving image as below,
do {
try imageData?.write(to: url)
logGPSData(imageData: imageData!)
} catch {
print("Error", error)
}
Reading GPS data as below, By adding location data.
func getGPSData(_ image: UIImage) {
let imageData = UIImageJPEGRepresentation(image, 1.0)
var source: CGImageSource? = nil
source = CGImageSourceCreateWithData((imageData as CFData?)!, nil)
let metadata = CGImageSourceCopyPropertiesAtIndex(source!, 0, nil) as? [AnyHashable: Any]
var metadataAsMutable = metadata
if let GPSDictionary = (metadataAsMutable?[(kCGImagePropertyGPSDictionary as String)]) as? [AnyHashable: Any] {
print(GPSDictionary.debugDescription)
}else {
print("no GPS Data")
}
print(metadata?.debugDescription)
}
Do I am missing anything? Please guide me here.