Stickers Import Improvements

This commit is contained in:
Ilya Laktyushin
2021-06-18 07:59:10 +03:00
parent 3d81bf7ad8
commit d8e36f149f
3 changed files with 227 additions and 65 deletions

View File

@@ -168,7 +168,13 @@ private func videoFirstFrameData(account: Account, resource: MediaResource, chun
private func fetchCachedStickerAJpegRepresentation(account: Account, resource: MediaResource, resourceData: MediaResourceData, representation: CachedStickerAJpegRepresentation) -> Signal<CachedMediaResourceRepresentationResult, NoError> {
return Signal({ subscriber in
if let data = try? Data(contentsOf: URL(fileURLWithPath: resourceData.path), options: [.mappedIfSafe]) {
if let image = WebP.convert(fromWebP: data) {
var image: UIImage?
if let webpImage = WebP.convert(fromWebP: data) {
image = webpImage
} else if let pngImage = UIImage(data: data) {
image = pngImage
}
if let image = image {
let path = NSTemporaryDirectory() + "\(Int64.random(in: Int64.min ... Int64.max))"
let url = URL(fileURLWithPath: path)