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
}
let maxPixelSize: Int
if Bundle.main.bundlePath.hasSuffix(".appex") {
maxPixelSize = 1536
} else {
maxPixelSize = 4096
}
let downsampleOptions = [
kCGImageSourceCreateThumbnailFromImageAlways: true,
kCGImageSourceCreateThumbnailWithTransform: true,
kCGImageSourceThumbnailMaxPixelSize: 4096,
] as CFDictionary
kCGImageSourceThumbnailMaxPixelSize: maxPixelSize,
] as [CFString : Any] as CFDictionary
guard let cgImage = CGImageSourceCreateThumbnailAtIndex(source, 0, downsampleOptions) else {
continuation.resume(returning: nil)