add scaling, only for images atm

This commit is contained in:
neon443
2025-11-30 18:57:39 +00:00
parent 1de0214c43
commit 74d6b29f69

View File

@@ -77,11 +77,14 @@ struct Emoji: Codable, Identifiable, Hashable {
let _ = UIImage(data: data) {
return
}
let (data, _) = try await URLSession.shared.data(from: remoteImageURL)
if let cgImage = UIImage(data: data)?.cgImage,
var (data, _) = try await URLSession.shared.data(from: remoteImageURL)
if let uiImage = UIImage(data: data),
let cgImage = UIImage(data: data)?.cgImage,
await !self.localImageURLString.contains(".gif"),
cgImage.width < 300 || cgImage.height < 300 {
data = await resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
}
try! await data.write(to: localImageURL)
return