mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-07 16:11:13 +00:00

git-subtree-dir: submodules/TelegramUI git-subtree-mainline: 5c1613d1048026b9e00a6ce753775cef87eb53fa git-subtree-split: fa3ac0b61a27c8dd3296518a15891a6f9750cbf2
20 lines
749 B
Swift
20 lines
749 B
Swift
import Foundation
|
|
import UIKit
|
|
import Postbox
|
|
import Display
|
|
|
|
func prepareSecretThumbnailData(_ data: MediaResourceData) -> (CGSize, Data)? {
|
|
if data.complete, let image = UIImage(contentsOfFile: data.path) {
|
|
if image.size.width < 100 && image.size.height < 100 {
|
|
if let resultData = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
|
|
return (image.size, resultData)
|
|
}
|
|
}
|
|
let scaledSize = image.size.fitted(CGSize(width: 90.0, height: 90.0))
|
|
if let scaledImage = generateScaledImage(image: image, size: scaledSize, scale: 1.0), let scaledData = UIImageJPEGRepresentation(scaledImage, 0.4) {
|
|
return (scaledSize, scaledData)
|
|
}
|
|
}
|
|
return nil
|
|
}
|