Scale images to smaller size
This commit is contained in:
parent
300c1849fb
commit
902c4b08c4
@ -5,8 +5,6 @@ import CryptoKit
|
|||||||
|
|
||||||
final class Database: ObservableObject {
|
final class Database: ObservableObject {
|
||||||
|
|
||||||
private let imageCompressionQuality: CGFloat = 0.3
|
|
||||||
|
|
||||||
@AppStorage("classifier")
|
@AppStorage("classifier")
|
||||||
private var storedLocalClassifierVersion = 0 {
|
private var storedLocalClassifierVersion = 0 {
|
||||||
didSet { localClassifierVersion = storedLocalClassifierVersion }
|
didSet { localClassifierVersion = storedLocalClassifierVersion }
|
||||||
|
@ -17,6 +17,8 @@ final class ImageCache: ObservableObject {
|
|||||||
|
|
||||||
private let imageQuality: CGFloat = 0.3
|
private let imageQuality: CGFloat = 0.3
|
||||||
|
|
||||||
|
private let imageSize: CGSize = .init(width: 360, height: 360)
|
||||||
|
|
||||||
@Published
|
@Published
|
||||||
private(set) var imageCount = 0
|
private(set) var imageCount = 0
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ final class ImageCache: ObservableObject {
|
|||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
func save(_ image: UIImage, for cap: CapImage) -> Bool {
|
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
|
return false
|
||||||
}
|
}
|
||||||
let localUrl = localImageUrl(cap)
|
let localUrl = localImageUrl(cap)
|
||||||
|
Loading…
Reference in New Issue
Block a user