I am retrieving an image using
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) }
let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
}
I can retrieve the image, also use the image to input to a button background or whatever else I would like, but I cannot seem to retrieve the metadata of the photo. Now, there is a lot of talk on various other locations on the interwebs of using ALAssets
and their techniques for image data, BUT, ALAssets
is deprecated as of recently. Since my image is not an image that the user just took, but instead an image choosing from the camera roll, I am unable to use :
let metadata = info[UIImagePickerControllerMediaMetaData] as! NSDictionary
So, if anyone could point me in the correct direction as to how to get the metadata of an image that a user just picks from their camera roll, without using ALAssets, it would be greatly appreciated! Thanks!
If you want to get images from camera roll then this would help :
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let imageUrl = info["UIImagePickerControllerReferenceURL"]
let asset = PHAsset.fetchAssetsWithALAssetURLs([imageUrl], options: nil).firstObject as! PHAsset
print("location: " + String(asset.location))
print("Creation Date: " + String(asset.creationDate))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With