From 3fea43cf8337e9e094d2b3c13b028ed8c4e4dd23 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 04:36:50 -0500 Subject: [PATCH] Match Apple HEIF chroma reconstruction --- crates/image-codecs/src/codecs/heif.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/image-codecs/src/codecs/heif.rs b/crates/image-codecs/src/codecs/heif.rs index 775891ed8..c3fb33508 100644 --- a/crates/image-codecs/src/codecs/heif.rs +++ b/crates/image-codecs/src/codecs/heif.rs @@ -55,7 +55,14 @@ pub(crate) fn decode(bytes: &[u8], limits: &Limits, keep_orientation: bool) -> R if !keep_orientation && (info.coded_width, info.coded_height) != (w, h) { limits.check(info.coded_width, info.coded_height, layout, sample)?; } - let options = craft_heif::Options { max_pixels: limits.max_pixels, apply_transforms: !keep_orientation, ..Default::default() }; + let options = craft_heif::Options { + max_pixels: limits.max_pixels, + apply_transforms: !keep_orientation, + // PhotoCraft's HEIF fixtures and export expectations match Apple's decoder. In + // particular, its left-sited bilinear chroma reconstruction differs at sharp edges + // from the libheif default, even though both produce the same RGB strip centres. + chroma: craft_heif::Chroma::Apple, + }; let decoded = craft_heif::decode(bytes, &options).map_err(err)?; // The decoder re-reads the container; trust its output's shape, not the probe's. let layout = if decoded.has_alpha { ChannelLayout::Rgba } else { ChannelLayout::Rgb };