You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to get the path of selected images. But, using phAsset from metadata returns nil. I tried the following:
None of the ways in the following function worked.
` func getImagesFromAsset(asset: PHAsset) -> URL? {
var finalURL: URL?
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
let imageRequestOptions = PHImageRequestOptions()
PHImageManager.default().requestImageData(for: asset, options: imageRequestOptions, resultHandler: { imageData, dataUTI, orientation, info in
if let info = info {
print("info = \(info)")
}
if info?["PHImageFileURLKey"] != nil {
let path = info?["PHImageFileURLKey"] as? URL
print(path) //here you get complete URL
// if you want to save image in document see this.
// self.saveimageindocument(imageData, withimagename: "DEMO")
}
})
asset.requestContentEditingInput(with: options) { (editingInput, info) in
if asset.mediaType == .image {
if let strURL = editingInput?.fullSizeImageURL?.absoluteString {
print("IMAGE URL: ", strURL)
} else {
print("nill")
}
}
}
asset.requestContentEditingInput(with: options) { (eidtingInput, info) in
if #available(iOS 11.0, *) {
let imgUrl = info[UIImagePickerController.InfoKey.imageURL] as? URL
} else {
// Fallback on earlier versions
}
print("Here")
// print(imgUrl)
print(info)
print(eidtingInput)
if let input = eidtingInput, let imgURL = input.fullSizeImageURL {
// imgURL
print(imgURL)
finalURL = imgURL
}
}
return finalURL
}`
The text was updated successfully, but these errors were encountered:
I want to get the path of selected images. But, using phAsset from metadata returns nil. I tried the following:
None of the ways in the following function worked.
` func getImagesFromAsset(asset: PHAsset) -> URL? {
var finalURL: URL?
// PHImageManager.default().requestImage(for: asset, targetSize: CGSize(width: 600, height: 600), contentMode: .aspectFill, options: nil, resultHandler: { (image, info) in
// //resultHandler have info ([AnyHashable: Any])
// print(info!["PHImageFileURLKey"])
// finalURL = info!["PHImageFileURLKey"] as! URL
//
// })
// print(imgUrl)
print(info)
print(eidtingInput)
The text was updated successfully, but these errors were encountered: