Scale images to smaller size
This commit is contained in:
parent
300c1849fb
commit
902c4b08c4
@ -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 }
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user