What is equivalent method of ALAsssetsLibrary’s assetForURL:resultBlock:failure in Photos Framework?

435 Views Asked by At

I am picking image using UIImagePickerController but I also need image’s name and other metadata information. I could have fetched image asset using ALAsssetsLibrary’s assetForURL:resultBlock:failure method with the help of referenceURL provided by UIImagePickerController after picking image but that method/Framework is deprecated in iOS9. I searched for its equivalent method in Photos Framework but I didn’t find one.

Let me know its equivalent method or any other way to fetch selected image’s metadata using Photos Framework.

1

There are 1 best solutions below

0
Kemal Can Kaynak On

Yes you can read metada with Photos Framework like that;

asset.requestContentEditingInputWithOptions(options) { (fooContentEditingInput: PHContentEditingInput!, _) -> Void in
    //Get full image
    let imageUrl = fooContentEditingInput.fullSizeImageURL
    let orientation = fooContentEditingInput.fullSizeImageOrientation
    var finalImage = CIImage(contentsOfURL: imageUrl)
    finalImage = inputImage.imageByApplyingOrientation(orientation)

    for (key, value) in finalImage.properties() {
        println("key: \(key)")
        println("value: \(value)")
    }
}