Scale images to smaller size

This commit is contained in:
Christoph Hagen 2023-10-25 12:38:16 +02:00
parent 300c1849fb
commit 902c4b08c4
2 changed files with 3 additions and 3 deletions

View File

@ -5,8 +5,6 @@ import CryptoKit
final class Database: ObservableObject {
private let imageCompressionQuality: CGFloat = 0.3
@AppStorage("classifier")
private var storedLocalClassifierVersion = 0 {
didSet { localClassifierVersion = storedLocalClassifierVersion }

View File

@ -17,6 +17,8 @@ final class ImageCache: ObservableObject {
private let imageQuality: CGFloat = 0.3
private let imageSize: CGSize = .init(width: 360, height: 360)
@Published
private(set) var imageCount = 0
@ -41,7 +43,7 @@ final class ImageCache: ObservableObject {
@discardableResult
func save(_ image: UIImage, for cap: CapImage) -> Bool {
guard let data = image.jpegData(compressionQuality: imageQuality) else {
guard let data = image.resize(to: imageSize).jpegData(compressionQuality: imageQuality) else {
return false
}
let localUrl = localImageUrl(cap)