diff --git a/crates/engine-core/src/cmd/image_cmds.rs b/crates/engine-core/src/cmd/image_cmds.rs index fb5c321294..0264bf7135 100644 --- a/crates/engine-core/src/cmd/image_cmds.rs +++ b/crates/engine-core/src/cmd/image_cmds.rs @@ -1239,7 +1239,10 @@ fn plan_depth_crossing(doc: &Document, current: SampleType, depth: SampleType) - }; (DepthTone::DefaultTransfer(default_transfer), Some(bytes)) } - Some(_) => (DepthTone::None, None), + // 32-bit float documents always hold linear light (including older files tagged + // with an encoded profile), so narrow through the transfer curve while keeping + // the existing encoded profile. + Some(_) => (DepthTone::DefaultTransfer(default_transfer), None), } } } @@ -1262,7 +1265,7 @@ fn plan_depth_crossing(doc: &Document, current: SampleType, depth: SampleType) - match own { None => (DepthTone::DefaultTransfer(default_transfer), None), Some(ref p) if is_linear(p) => (DepthTone::DefaultTransfer(default_transfer), Some(Builtin::DotGain20Compat.profile().to_bytes())), - Some(_) => (DepthTone::None, None), + Some(_) => (DepthTone::DefaultTransfer(default_transfer), None), } } } diff --git a/crates/engine-core/src/cmd/image_cmds/tests.rs b/crates/engine-core/src/cmd/image_cmds/tests.rs index d512472300..64072facdf 100644 --- a/crates/engine-core/src/cmd/image_cmds/tests.rs +++ b/crates/engine-core/src/cmd/image_cmds/tests.rs @@ -1203,6 +1203,10 @@ fn thirty_two_bit_export_keeps_colour_in_exr_and_png() { craft_cms::Profile::parse(png_icc).unwrap().same_colors(craft_cms::Builtin::LinearSrgb.profile()), "PNG export of a 32-bit document must embed linear sRGB, not sRGB" ); + let png_px = png_doc.layers[0].surface().unwrap().pixel(0, 0); + for (got, want) in png_px.iter().zip([0.23455f32, 0.57758, 0.02122]) { + assert!((got - want).abs() < 1e-3, "PNG pixel {png_px:?} vs {want}"); + } // Untagged / non-ICC export (BMP) converts from linear sRGB back to 8-bit sRGB 133/200/40. let bmp = photocraft_io::export(d, "out.bmp", &photocraft_io::ExportOptions::default()).unwrap();