DKImagePickerController icon indicating copy to clipboard operation
DKImagePickerController copied to clipboard

'image' property inside 'DKAsset' is nil

Open rezwan-islam opened this issue 4 years ago • 3 comments

Under the DKImagePickerController's didSelectAssets code block the image property inside DKAsset is nil pickerController.didSelectAssets = { (assets: [DKAsset]) in print(assets.first?.image) //prints nil }

rezwan-islam avatar Dec 20 '20 11:12 rezwan-islam

Yes, exactly. It doesnt work as exzpected.

kunass2 avatar Mar 20 '21 06:03 kunass2

Under the DKImagePickerController's didSelectAssets code block the image property inside DKAsset is nil pickerController.didSelectAssets = { (assets: [DKAsset]) in print(assets.first?.image) //prints nil }

mralirazaamjad avatar Aug 20 '21 06:08 mralirazaamjad

I tried this solution and it worked.

class func getUIImage(asset: PHAsset) -> UIImage? {
    var img: UIImage?

    let options = PHImageRequestOptions()
    options.deliveryMode = .highQualityFormat
    options.isSynchronous = true // Set it to false for async callback

    let imageManager = PHCachingImageManager()
    imageManager.requestImage(for: asset, targetSize: CGSize(width: asset.pixelWidth, height: asset.pixelHeight), contentMode: .aspectFill, options: options) { image, info in
        img = image
    }
    
    return img
}

zeldarose avatar Aug 31 '21 02:08 zeldarose