longitachi / ZLPhotoBrowser

Wechat-like image picker. Support select photos, videos, gif and livePhoto. Support edit image and crop video. 微信样式的图片选择器,支持预览/相册内拍照及录视频、拖拽/滑动选择,编辑图片/视频,支持多语言国际化等功能;
MIT License
4.72k stars 953 forks source link

gif图过大超过200帧显示崩溃 #803

Closed dianluyuanli closed 1 year ago

dianluyuanli commented 1 year ago

Issue Description

Description and Steps

Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.

Info

ZLPhotoBrowser version: e.g. 4.3.9 Device: e.g. iPhone X Device version: e.g. iOS 14.0 Xcode version: e.g. Xcode 12.0

Configuration code of ZLPhotoConfiguration

   Paste your code here.
dianluyuanli commented 1 year ago

ublic extension ZLPhotoBrowserWrapper where Base: UIImage { static func animateGifImage(data: Data) -> UIImage? { // Kingfisher let info: [String: Any] = [ kCGImageSourceShouldCache as String: true, kCGImageSourceTypeIdentifierHint as String: kUTTypeGIF ]

    guard let imageSource = CGImageSourceCreateWithData(data as CFData, info as CFDictionary) else {
        return UIImage(data: data)
    }

    let frameCount = CGImageSourceGetCount(imageSource)
    guard frameCount > 1 else {
        return UIImage(data: data)
    }

    let interval = max((frameCount+50/2)/50, 1)
    var images = [UIImage]()
    var frameDuration = [Int]()
longitachi commented 1 year ago

804