diff --git a/lib/src/darwin/native.dart b/lib/src/darwin/native.dart index a68e864..2511820 100644 --- a/lib/src/darwin/native.dart +++ b/lib/src/darwin/native.dart @@ -345,9 +345,11 @@ final class ImageConverterDarwin implements ImageConverterPlatform { final keys = arena>(3); final values = arena>(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 diff --git a/lib/src/darwin/orientation_bindings.dart b/lib/src/darwin/orientation_bindings.dart index 660f669..5528582 100644 --- a/lib/src/darwin/orientation_bindings.dart +++ b/lib/src/darwin/orientation_bindings.dart @@ -85,6 +85,17 @@ external ffi.Pointer kCGImagePropertyOrientation; @ffi.Native>() external ffi.Pointer 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>() +external ffi.Pointer kCGImageSourceCreateThumbnailFromImageAlways; + /// Key: when `kCFBooleanTrue`, rotates/flips the thumbnail to match the EXIF /// orientation tag, producing pixel-correct upright image data. @ffi.Native>()