1

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?

Zouhair Sassi
  • 1,403
  • 1
  • 13
  • 30
Teddy K
  • 820
  • 1
  • 6
  • 17

1 Answers1

1

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( .... )
}
NikR
  • 628
  • 4
  • 14