alexiscreuzot / SwiftyGif

High performance GIF engine
MIT License
2k stars 211 forks source link

How to use with photokit #147

Closed IMCHO closed 3 years ago

IMCHO commented 3 years ago

Hello I'm using PHAsset in PhotoKit and getting UIImage from requestImage() in my project. I saw SwiftyGif just supports from data or url to image. So I use this code like below.

guard let image = data.object as? UIImage else { return }
if let data = image.pngData() {
    do {
        let image = try UIImage(gifData: data)
    } catch let error {
        print(error.localizedDescription)
    }
}

data.object is NSObject(actually UIImage in that code) from requestImage() and I use pngData() to ready to use SwiftyGif. But I got error log like Invalid gif file.

What did I miss? Is there a better solution to use it with photokit?