public func setExiffrom(url:URL?){
if url == nil{
return
}
let imagedata = try! Data.init(contentsOf: url!)
let source: CGImageSource = CGImageSourceCreateWithData((imagedata as CFData), nil)!
if let object = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [String: Any]{
self.imageView.image = UIImage(data: imagedata)
self.exif = Exif(object)
self.textView.text = self.exif?.gps?.getFormattedString(valueSeperator: " = ", lineSeperator: "")
}
}
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let image = info[UIImagePickerControllerOriginalImage] as? UIImage
let url = info[UIImagePickerControllerImageURL] as? URL
self.imageView.image = image
self.choosenImage = image
self.setExiffrom(url: url)
self.dismiss(animated: true, completion: nil)
}
I would like to incorporate reading the location of a user's photos into an app so I learned about exif and how it is where lat/lon are stored. I had someone help me with the coding and for some images in the app it would parse the exif out of the selected image fine... BUT for most images no location data was present in the exif. I checked in iOS Photos app, and in there the location data was correctly presented for all the images (pushing up on a photo shows it on a map)
I tested on my macbook as well and found something surprising. When I right clicked and clicked "get info" on an image on the Photos app on the macbook it displayed with the location, but as soon as I copied it to my desktop it no longer had the location data. A new security feature perhaps?
My question is how do I write an app that gets the location correctly so may app can help users capture memories? If the phone's Photos app can see the location then that means the data is there, so it is frustrating that whenever the image is copied it appears the location data is stripped. Perhaps I need to somehow read the data BEFORE I call the "let image = info[UIImagePickerControllerOriginalImage] because that is somehow stripping off the location info? If so how would I do that? Maybe there is just a better technique?
-- any help, would be appreciated, I am stumped...