Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Thumbnail Image from PHAsset

I want to get the Thumbnail Image of my PHAsset. I already extracted a PHAsset from the Photo Library and want to get the Thumbnail Image now.

Can you help me in Objective-C?

Thanks!

like image 674
Peter Avatar asked Jun 08 '26 05:06

Peter


2 Answers

In case someone is looking for a swift solution, here is an extension:

extension PHAsset {
    var thumbnailImage : UIImage {
        get {
            let manager = PHImageManager.default()
            let option = PHImageRequestOptions()
            var thumbnail = UIImage()
            option.isSynchronous = true
            manager.requestImage(for: self, targetSize: CGSize(width: 300, height: 300), contentMode: .aspectFit, options: option, resultHandler: {(result, info)->Void in
                thumbnail = result!
            })
            return thumbnail
        }
    }
}
like image 135
Francois Nadeau Avatar answered Jun 10 '26 18:06

Francois Nadeau


The PHImageManagerClass has the method:

- requestImageForAsset:targetSize:contentMode:options:resultHandler:
like image 22
Abizern Avatar answered Jun 10 '26 19:06

Abizern