Fix image max size in app extension

This commit is contained in:
Thomas Ricouard 2023-03-12 11:43:15 +01:00
parent 6f484fa6c5
commit 8b4f6dbd05

View file

@ -15,11 +15,18 @@ actor StatusEditorCompressor {
return return
} }
let maxPixelSize: Int
if Bundle.main.bundlePath.hasSuffix(".appex") {
maxPixelSize = 1536
} else {
maxPixelSize = 4096
}
let downsampleOptions = [ let downsampleOptions = [
kCGImageSourceCreateThumbnailFromImageAlways: true, kCGImageSourceCreateThumbnailFromImageAlways: true,
kCGImageSourceCreateThumbnailWithTransform: true, kCGImageSourceCreateThumbnailWithTransform: true,
kCGImageSourceThumbnailMaxPixelSize: 4096, kCGImageSourceThumbnailMaxPixelSize: maxPixelSize,
] as CFDictionary ] as [CFString : Any] as CFDictionary
guard let cgImage = CGImageSourceCreateThumbnailAtIndex(source, 0, downsampleOptions) else { guard let cgImage = CGImageSourceCreateThumbnailAtIndex(source, 0, downsampleOptions) else {
continuation.resume(returning: nil) continuation.resume(returning: nil)