add scaling, only for images atm

This commit is contained in:
neon443 committed 2025-11-30 18:57:39 +00:00
1 parent 1de0214c43
commit 74d6b29f69
1 file changed
+7 -4
+7 -4
View File
@@ -74,14 +74,17 @@ struct Emoji: Codable, Identifiable, Hashable {
nonisolated nonisolated
func downloadImage() async throws { func downloadImage() async throws {
if let data = try? await Data(contentsOf: localImageURL), if let data = try? await Data(contentsOf: localImageURL),
let _ = UIImage(data: data) { let _ = UIImage(data: data) {
return 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 { cgImage.width < 300 || cgImage.height < 300 {
data = await resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
} }
try! await data.write(to: localImageURL) try! await data.write(to: localImageURL)
return return
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.