I am using UIImagePickerController
to select images. I was hoping to get the local path too.
I am doing this for images in an album using
info[UIImagePickerController.InfoKey.imageURL] as? URL
In the case of an image using the camera this is nil
however.
Is it possible to capture this path using UIImagePickerControllerDelegate
?
Yes, but with another key:
info[UIImagePickerController.InfoKey.originalImage] as? UIImage
or
info[UIImagePickerController.InfoKey.editedImage] as? UIImage
Please note that the object there will be UIImage type, not URL
Camera photos are not saved by default and don't have local path. So you need to save it by yourself. E.g.:
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
try? image.pngData()?.write( .... )
}