I'm in throubles accessing original HEIC and DNG files from my iOS 11 app, written in Swift; following the Apple developer's documentation, to access original files it's enought to set
imagePicker.imageExportPreset = UIImagePickerController.ImageURLExportPreset.current
but on the UIImagePickerController.InfoKey.imageURL
I still get an URL pointing to a JPEG file; I know the choosen pictures are HEIC and DNG because exporting as original on Mac photo app I get the original file format.This is the complete code I use:
@IBAction func openRoll(_ sender: Any) {
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = false
imagePicker.imageExportPreset = .current
self.present(imagePicker, animated: true, completion: nil)
}
}
And on delegate:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage
let path = info[UIImagePickerController.InfoKey.imageURL] as! NSURL
NSLog("URL: \(path.absoluteString)")
NSLog("Export: \(picker.imageExportPreset.rawValue)")
dismiss(animated:true, completion: nil)
// ...code to use the image!
}
Thank you very much for help, suggestions and working snippets.