fix: use kCGImageSourceCreateThumbnailFromImageAlways for full-res orientation fix
This commit is contained in:
parent
32e37d2b5f
commit
92b967bfc5
|
|
@ -345,9 +345,11 @@ final class ImageConverterDarwin implements ImageConverterPlatform {
|
|||
final keys = arena<Pointer<Void>>(3);
|
||||
final values = arena<Pointer<Void>>(3);
|
||||
|
||||
// kCGImageSourceCreateThumbnailFromImageIfAbsent = kCFBooleanTrue
|
||||
// Use 1.toNSNumber() — bool has no toNSNumber() extension; NSNumber(1) = YES.
|
||||
keys[0] = kCGImageSourceCreateThumbnailFromImageIfAbsent.cast();
|
||||
// kCGImageSourceCreateThumbnailFromImageAlways = kCFBooleanTrue
|
||||
// MUST use "Always" not "IfAbsent": iPhone HEIC files embed a tiny
|
||||
// ~240x320 JPEG thumbnail. "IfAbsent" returns that embedded thumbnail
|
||||
// instead of decoding the full image, giving very low-resolution output.
|
||||
keys[0] = kCGImageSourceCreateThumbnailFromImageAlways.cast();
|
||||
values[0] = 1.toNSNumber().ref.retainAndAutorelease().cast();
|
||||
|
||||
// kCGImageSourceCreateThumbnailWithTransform = kCFBooleanTrue
|
||||
|
|
|
|||
|
|
@ -85,6 +85,17 @@ external ffi.Pointer<objc.CFString> kCGImagePropertyOrientation;
|
|||
@ffi.Native<ffi.Pointer<objc.CFString>>()
|
||||
external ffi.Pointer<objc.CFString> kCGImageSourceCreateThumbnailFromImageIfAbsent;
|
||||
|
||||
/// Key: when `kCFBooleanTrue`, ALWAYS creates a thumbnail from the full source
|
||||
/// image data, ignoring any embedded thumbnail.
|
||||
///
|
||||
/// **Use this instead of [kCGImageSourceCreateThumbnailFromImageIfAbsent] when
|
||||
/// full-resolution output is required.** iPhone HEIC files always contain a
|
||||
/// tiny embedded JPEG thumbnail (~240×320). Without this key, ImageIO returns
|
||||
/// the embedded thumbnail rather than decoding the full image, producing a very
|
||||
/// low-resolution output regardless of [kCGImageSourceThumbnailMaxPixelSize].
|
||||
@ffi.Native<ffi.Pointer<objc.CFString>>()
|
||||
external ffi.Pointer<objc.CFString> kCGImageSourceCreateThumbnailFromImageAlways;
|
||||
|
||||
/// Key: when `kCFBooleanTrue`, rotates/flips the thumbnail to match the EXIF
|
||||
/// orientation tag, producing pixel-correct upright image data.
|
||||
@ffi.Native<ffi.Pointer<objc.CFString>>()
|
||||
|
|
|
|||
Loading…
Reference in New Issue