Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'image' property inside 'DKAsset' is nil #680

Open
rezwan-islam opened this issue Dec 20, 2020 · 3 comments
Open

'image' property inside 'DKAsset' is nil #680

rezwan-islam opened this issue Dec 20, 2020 · 3 comments

Comments

@rezwan-islam
Copy link

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 }

@kunass2
Copy link

kunass2 commented Mar 20, 2021

Yes, exactly. It doesnt work as exzpected.

@mralirazaamjad
Copy link

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 }

@zeldarose
Copy link

zeldarose commented Aug 31, 2021

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants