PhotoCraft: An open-source, photo editor written by scratch in pure Rust
CMYK: Hue/Saturation and Color Balance keep the black ink (#5000)
Timothy Dalya62ef68ca249
diff --git a/crates/compose/src/adjust.rs b/crates/compose/src/adjust.rsindex 87f41030a..f91e7779d 100644--- a/crates/compose/src/adjust.rs+++ b/crates/compose/src/adjust.rs@@ -316,6 +316,15 @@ pub fn apply_in(adj: &Adjustment, buf: &mut Buffer, transfer: Transfer, depth: Oif let Adjustment::BrightnessContrast { brightness, contrast, legacy } = adj {let table = ink_brightness_contrast_lut(*brightness, *contrast, *legacy);map_rgb(buf, |c| cmyk_to_rgb(rgb_to_cmyk(c).map(|v| ink_through(&table, v))));+ } else if cmy_adjustment(adj) {+ let mut inks: Vec<[f32; 4]> = buf.px.iter().map(|p| rgb_to_cmyk([p[0], p[1], p[2]])).collect();+ apply_cmy(adj, &mut inks);+ for (p, ink) in buf.px.iter_mut().zip(&inks) {+ if p[3] > 0.0 {+ let [r, g, b] = cmyk_to_rgb(*ink);+ (p[0], p[1], p[2]) = (r, g, b);+ }+ }} else {map_rgb(buf, |c| {let mut ink = rgb_to_cmyk(c);@@ -351,7 +360,29 @@ pub fn lab_channel_adjustment(adj: &Adjustment) -> bool {/// every pixel; here the inks are the screen colour separated through the document's CMYK/// profile, so neutrals carry the black that profile generates rather than the file's.pub fn cmyk_channel_adjustment(adj: &Adjustment) -> bool {- stored_channel_adjustment(adj) || matches!(adj, Adjustment::BrightnessContrast { .. })+ stored_channel_adjustment(adj) || cmy_adjustment(adj) || matches!(adj, Adjustment::BrightnessContrast { .. })+}++/// Whether a CMYK document evaluates `adj` on C, M and Y as the complement of an RGB colour,+/// black kept ([`apply_cmy`]): Hue/Saturation (not Colorize, which Photoshop separates again,+/// black and all) and Color Balance (photoshop corpus cmyk16 hue-saturation.psd follows this on+/// every pixel within half a level, cmyk8 within two; color-balance within our RGB Color+/// Balance's own error).+pub fn cmy_adjustment(adj: &Adjustment) -> bool {+ matches!(adj, Adjustment::HueSaturation { colorize: false, .. } | Adjustment::ColorBalance { .. })+}++/// A [`cmy_adjustment`] on straight inks (C, M, Y, K; 0 none): the RGB adjustment on+/// `(1 - c, 1 - m, 1 - y)`, black left alone.+pub fn apply_cmy(adj: &Adjustment, inks: &mut [[f32; 4]]) {+ let width = i32::try_from(inks.len()).unwrap_or(i32::MAX);+ let mut buf = Buffer { rect: crate::Rect::new(0, 0, width, 1), px: inks.iter().map(|i| [1.0 - i[0], 1.0 - i[1], 1.0 - i[2], 1.0]).collect() };+ apply_depth(adj, &mut buf, Transfer::Srgb, None);+ for (ink, p) in inks.iter_mut().zip(&buf.px) {+ for c in 0..3 {+ ink[c] = (1.0 - p[c]).clamp(0.0, 1.0);+ }+ }}/// Brightness/Contrast as the lookup table (4096 samples over 0..1) a CMYK ink's stored value,diff --git a/crates/compose/src/native.rs b/crates/compose/src/native.rsindex e2bc653d7..31e17f3ea 100644--- a/crates/compose/src/native.rs+++ b/crates/compose/src/native.rs@@ -9,7 +9,8 @@//! it does there.//!//! Plain adjustment layers that Photoshop evaluates on the inks (Invert, Posterize, Threshold,-//! Brightness/Contrast, and Levels and Curves on CMYK channels) join such a stack too: on the+//! Brightness/Contrast, Hue/Saturation, Color Balance, and Levels and Curves on CMYK channels)+//! join such a stack too: on the//! stored inks their rules are exact, where the RGB compositor can only apply them to a separation//! of its RGB composite, whose black differs from the file's. Such stacks are also rendered for//! display this way ([`render_cmyk`]); stacks of raster layers alone keep the RGB compositor there.@@ -55,18 +56,26 @@ enum InkOp<'a> {Tables([Vec<f32>; INKS]),/// Invert, Posterize or Threshold (`adjust::stored_channels`).Rules(&'a Adjustment),+ /// Hue/Saturation or Color Balance on C, M and Y as inverted RGB (`adjust::apply_cmy`).+ Cmy(&'a Adjustment),}impl InkOp<'_> {- fn apply(&self, ink: &mut [f32; INKS], depth: SampleType) {+ /// The adjusted inks of each pixel of `inks` that has coverage (its fifth value).+ fn apply(&self, inks: &[[f32; INKS + 1]], depth: SampleType) -> Vec<[f32; INKS]> {+ let mut out: Vec<[f32; INKS]> = inks.iter().map(|d| [d[0], d[1], d[2], d[3]]).collect();match self {InkOp::Tables(t) => {- for (v, table) in ink.iter_mut().zip(t) {- *v = adjust::ink_through(table, *v);+ for ink in &mut out {+ for (v, table) in ink.iter_mut().zip(t) {+ *v = adjust::ink_through(table, *v);+ }}}- InkOp::Rules(adj) => adjust::stored_channels(adj, ColorMode::Cmyk, Some(depth), ink),+ InkOp::Rules(adj) => out.iter_mut().for_each(|ink| adjust::stored_channels(adj, ColorMode::Cmyk, Some(depth), ink)),+ InkOp::Cmy(adj) => adjust::apply_cmy(adj, &mut out),}+ out}}@@ -78,6 +87,7 @@ fn ink_op(layer: &Layer, depth: SampleType) -> Option<InkOp<'_>> {}match adj {Adjustment::Invert | Adjustment::Posterize { .. } | Adjustment::Threshold { .. } => Some(InkOp::Rules(adj)),+ _ if adjust::cmy_adjustment(adj) => Some(InkOp::Cmy(adj)),Adjustment::BrightnessContrast { brightness, contrast, legacy } => {let t = adjust::ink_brightness_contrast_lut(*brightness, *contrast, *legacy);Some(InkOp::Tables([t.clone(), t.clone(), t.clone(), t]))@@ -205,13 +215,12 @@ impl<'a> InkStack<'a> {continue;}masked(*mask, mv);- for (d, k) in acc.iter_mut().zip(mv.iter()) {+ let adjusted = op.apply(acc, self.depth);+ for ((d, k), ink) in acc.iter_mut().zip(mv.iter()).zip(&adjusted) {let mix = opacity * k.clamp(0.0, 1.0);if d[INKS] <= 0.0 || mix <= 0.0 {continue;}- let mut ink = [d[0], d[1], d[2], d[3]];- op.apply(&mut ink, self.depth);for (c, v) in ink.iter().enumerate() {d[c] += (v - d[c]) * mix;}diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rsindex 64c33e6c8..d8842a24f 100644--- a/crates/compose/src/tests.rs+++ b/crates/compose/src/tests.rs@@ -665,8 +665,8 @@ fn only_cmyk_stacks_with_ink_adjustments_render_on_their_inks() {assert!(native::render_cmyk(&d, r, 64).is_none(), "plain layers");d.layers.push(Layer::new("inv", LayerContent::Adjustment(Adjustment::Invert)));assert!(native::render_cmyk(&d, r, 64).is_some());- let hue = Adjustment::HueSaturation { hue: 30.0, saturation: 0.0, lightness: 0.0, colorize: false, ranges: photocraft_doc::adjust::HueRange::defaults() };- d.layers.push(Layer::new("hue", LayerContent::Adjustment(hue)));+ let exposure = Adjustment::Exposure { exposure: 0.5, offset: 0.0, gamma: 1.0 };+ d.layers.push(Layer::new("exposure", LayerContent::Adjustment(exposure)));assert!(native::render_cmyk(&d, r, 64).is_none(), "an adjustment the inks don't carry");d.layers.pop();d.layers[1].blend = BlendMode::Multiply;@@ -681,6 +681,37 @@ fn only_cmyk_stacks_with_ink_adjustments_render_on_their_inks() {assert_eq!(render_tiled(&d, d.bounds(), 1).px, whole.px);}+/// Hue/Saturation (not Colorize) and Color Balance work on C, M and Y as inverted RGB with the+/// black ink kept (photoshop corpus cmyk16 hue-saturation.psd: every ink within half a level).+#[test]+fn cmyk_hue_saturation_and_color_balance_keep_the_black_ink() {+ use photocraft_color::convert::cmyk_to_rgb;+ let ranges = photocraft_doc::adjust::HueRange::defaults();+ let hue = Adjustment::HueSaturation { hue: 40.0, saturation: 25.0, lightness: -10.0, colorize: false, ranges: ranges.clone() };+ let balance =+ Adjustment::ColorBalance { shadows: [20.0, -10.0, 0.0], midtones: [-15.0, 10.0, 30.0], highlights: [0.0, 0.0, -20.0], preserve_luminosity: true };+ for adj in [hue, balance] {+ assert!(adjust::cmy_adjustment(&adj) && adjust::cmyk_channel_adjustment(&adj));+ let mut d = cmyk_doc([0.2, 0.7, 0.1, 0.3], SampleType::U16);+ let stored: [f32; 4] = std::array::from_fn(|c| d.layers[0].surface().unwrap().pixel(0, 0)[c]);+ d.layers.push(Layer::new("adj", LayerContent::Adjustment(adj.clone())));+ // The RGB adjustment on the inks' complement, black untouched.+ let mut rgb = Buffer::filled(Rect::new(0, 0, 1, 1), [1.0 - stored[0], 1.0 - stored[1], 1.0 - stored[2], 1.0]);+ adjust::apply(&adj, &mut rgb);+ let want = [1.0 - rgb.px[0][0], 1.0 - rgb.px[0][1], 1.0 - rgb.px[0][2], stored[3]];+ assert!(native::render_cmyk(&d, d.bounds(), 64).is_some(), "{}", adj.label());+ let c = cmyk_to_rgb(want);+ assert!(close4(px(&d, 1, 1), [c[0], c[1], c[2], 1.0]), "{}", adj.label());+ let flat = flatten_to_surface(&d, d.pixel_format(), None);+ let got = flat.pixel(1, 1);+ assert!((got[3] - stored[3]).abs() < 1e-4, "{}: black kept", adj.label());+ assert!((0..3).all(|i| (got[i] - want[i]).abs() < 1e-3), "{}: {got:?} vs {want:?}", adj.label());+ }+ // Colorize separates its colour again (black included), so it stays on the screen colour.+ let colorize = Adjustment::HueSaturation { hue: -160.0, saturation: 40.0, lightness: 5.0, colorize: true, ranges };+ assert!(!adjust::cmy_adjustment(&colorize) && !adjust::cmyk_channel_adjustment(&colorize));+}+/// Groups at full opacity without a mask are inlined: a pass-through group's adjustment reaches/// the layers below it, and an isolated group of raster layers composites as its children would./// An isolated group's adjustment (which only sees the group) or a translucent group keeps thediff --git a/crates/engine/src/pixels.rs b/crates/engine/src/pixels.rsindex bfc76eba4..f86cb1b55 100644--- a/crates/engine/src/pixels.rs+++ b/crates/engine/src/pixels.rs@@ -124,6 +124,9 @@ fn adjusted(s: &Surface, r: Rect, adj: &Adjustment, selection: Option<&Surface>,if fmt.mode == mode && matches!(mode, photocraft_color::ColorMode::Lab | photocraft_color::ColorMode::Cmyk) && adjust::stored_channel_adjustment(adj) {return adjusted_channels(s, r, selection, |ch| adjust::stored_channels(adj, fmt.mode, Some(fmt.sample), ch));}+ if fmt.mode == mode && mode == photocraft_color::ColorMode::Cmyk && adjust::cmy_adjustment(adj) {+ return adjusted_cmy(s, r, adj, selection);+ }if let Adjustment::BrightnessContrast { brightness, contrast, legacy } = adj&& fmt.mode == mode&& mode == photocraft_color::ColorMode::Cmyk@@ -172,6 +175,29 @@ fn adjusted_channels(s: &Surface, r: Rect, selection: Option<&Surface>, op: implraw}+/// [`adjusted`] for Hue/Saturation or Color Balance on a CMYK layer (`adjust::apply_cmy`): on its+/// stored C, M and Y, black kept, the whole region at once; the selection mixes the stored inks.+fn adjusted_cmy(s: &Surface, r: Rect, adj: &Adjustment, selection: Option<&Surface>) -> Vec<f32> {+ let fmt = s.format();+ let n = fmt.channels();+ let mut raw = s.read_region(r);+ let mut inks: Vec<[f32; 4]> = raw.chunks_exact(n).map(|p| std::array::from_fn(|c| p.get(c).copied().unwrap_or(0.0))).collect();+ adjust::apply_cmy(adj, &mut inks);+ let w = (r.width() as usize).max(1);+ let mut coverage = vec![1.0f32; w];+ for (j, (row, adjusted)) in raw.chunks_mut(w * n).zip(inks.chunks(w)).enumerate() {+ if let Some(sel) = selection {+ sel.sample_row_strided(r.y0.saturating_add(j as i32), r.x0, 1, 0, &mut coverage);+ }+ for ((px, ink), &k) in row.chunks_exact_mut(n).zip(adjusted).zip(&coverage) {+ for (v, a) in px.iter_mut().zip(ink) {+ *v += (a - *v) * k;+ }+ }+ }+ raw+}+/// `edited` mixed back over `orig` (straight RGBA over `r`, row-major) by the selection's/// coverage, encoded in `fmt`: what a destructive edit writes back through a selection.pub(crate) fn mix_through_selection(diff --git a/crates/engine/src/pixels_tests.rs b/crates/engine/src/pixels_tests.rsindex 13b63a6a3..5af30d0e7 100644--- a/crates/engine/src/pixels_tests.rs+++ b/crates/engine/src/pixels_tests.rs@@ -372,3 +372,25 @@ fn brightness_contrast_curves_cmyk_inks_as_stored() {}}}++/// Image › Adjustments › Hue/Saturation and Color Balance on a CMYK layer work on its stored C, M+/// and Y as inverted RGB, keep its black ink exactly, and mix through a selection.+#[test]+fn hue_saturation_and_color_balance_keep_a_cmyk_layers_black() {+ let cmyk = PixelFormat::new(ColorMode::Cmyk, SampleType::U16, true);+ let ink = [0.2, 0.7, 0.1, 0.3, 1.0];+ let hue =+ Adjustment::HueSaturation { hue: 40.0, saturation: 25.0, lightness: -10.0, colorize: false, ranges: photocraft_doc::adjust::HueRange::defaults() };+ let balance =+ Adjustment::ColorBalance { shadows: [20.0, -10.0, 0.0], midtones: [-15.0, 10.0, 30.0], highlights: [0.0, 0.0, -20.0], preserve_luminosity: true };+ for adj in [hue, balance] {+ let mut want = [[ink[0], ink[1], ink[2], ink[3]]];+ adjust::apply_cmy(&adj, &mut want);+ let got = adjusted_pixel(cmyk, &ink, &adj, None);+ assert!((0..4).all(|c| (got[c] - want[0][c]).abs() < 1e-4), "{}: {got:?} vs {want:?}", adj.label());+ assert!((got[3] - ink[3]).abs() < 1e-4 && got[4] == 1.0, "{}: black and alpha kept", adj.label());+ let half = adjusted_pixel(cmyk, &ink, &adj, Some(0.5));+ let k = 128.0 / 255.0;+ assert!((0..4).all(|c| (half[c] - (ink[c] + (want[0][c] - ink[c]) * k)).abs() < 1e-3), "{}: half a selection", adj.label());+ }+}diff --git a/crates/gpu/src/plan.rs b/crates/gpu/src/plan.rsindex de2003c1e..58ce6e429 100644--- a/crates/gpu/src/plan.rs+++ b/crates/gpu/src/plan.rs@@ -1836,6 +1836,11 @@ mod tests {let inks = !matches!(adj, Adjustment::GradientMap { .. });assert_eq!(adjustment_on_gpu(adj, ColorMode::Cmyk), !inks, "{adj:?} in CMYK");}+ // CMYK Hue/Saturation works on the inks (on the CPU); Colorize stays on the screen colour.+ let ranges = photocraft_doc::adjust::HueRange::defaults();+ let hue = |colorize| Adjustment::HueSaturation { hue: 30.0, saturation: 10.0, lightness: 0.0, colorize, ranges: ranges.clone() };+ assert!(!adjustment_on_gpu(&hue(false), ColorMode::Cmyk) && adjustment_on_gpu(&hue(true), ColorMode::Cmyk));+ assert!(adjustment_on_gpu(&hue(false), ColorMode::Rgb));// Screen-colour adjustments stay on the GPU in Lab documents.assert!(adjustment_on_gpu(&Adjustment::Exposure { exposure: 1.0, offset: 0.0, gamma: 1.0 }, ColorMode::Lab));}diff --git a/crates/io/tests/corpus.rs b/crates/io/tests/corpus.rsindex e08fbc5ef..a8d81a160 100644--- a/crates/io/tests/corpus.rs+++ b/crates/io/tests/corpus.rs@@ -148,15 +148,15 @@ struct Source {}/// Hand-picked mix in `corpus/psd` (170 files: 134 vs the merged image + 12 vs the thumbnail).-const MIXED: Source = Source { label: "io corpus", dir: "corpus/psd", group_depth: 0, pass_floor: 146, roundtrip_floor: 169 };+const MIXED: Source = Source { label: "io corpus", dir: "corpus/psd", group_depth: 0, pass_floor: 148, roundtrip_floor: 169 };/// The full psd-tools test set (309 files at the pinned commit; see `xtask/psd-tools-corpus.sha256`):/// 226 vs the merged image + 10 vs the thumbnail (Advanced Blending knockouts: +7).-const PSD_TOOLS: Source = Source { label: "psd-tools corpus", dir: "corpus/psd-tools", group_depth: 0, pass_floor: 242, roundtrip_floor: 308 };+const PSD_TOOLS: Source = Source { label: "psd-tools corpus", dir: "corpus/psd-tools", group_depth: 0, pass_floor: 249, roundtrip_floor: 308 };/// Our Photoshop-authored oracles (256 files; https://github.com/storytold/photocraft-corpus),/// grouped by feature (`smart-filters`, `effects`, `text`, `adjustments/<mode><bits>`).-const PHOTOSHOP: Source = Source { label: "photoshop oracles", dir: "corpus/photoshop", group_depth: 2, pass_floor: 165, roundtrip_floor: 258 };+const PHOTOSHOP: Source = Source { label: "photoshop oracles", dir: "corpus/photoshop", group_depth: 2, pass_floor: 185, roundtrip_floor: 258 };/// The corpus directory; a missing corpus fails the test.fn locate(src: &Source) -> PathBuf {diff --git a/docs/file-format-parity.md b/docs/file-format-parity.mdindex c960e2e1b..3543671cb 100644--- a/docs/file-format-parity.md+++ b/docs/file-format-parity.md@@ -1,6 +1,6 @@# File-format parity-> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-13 · **Change:** minor (CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026Every format Photoshop 2026 (27.11.0) reads or writes, with PhotoCraft's support, fidelity andtests. Photoshop's list comes from its `Info.plist` `CFBundleDocumentTypes`, the PiPL read/write@@ -21,7 +21,7 @@ XL are missing (gap G10). Remaining: 300–500 h including PSD fidelity.| Format | Photoshop | PhotoCraft read | PhotoCraft write | Fidelity and tests ||---|---|---|---|---|-| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 147/258, io 146/170, psd-tools 236/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) |+| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (14 mapped, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 185/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) || PSB | R/W | yes | yes | Auto-switches above 2 GB (REL-212-2); 4–5 GB fixtures generated (FILE-216-2); > 4 GB fails on Windows (#375) || Cloud PSD (.psdc) | R/W | no | no | Out of scope (Adobe cloud) || TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7: extra alpha channels not written) |@@ -142,6 +142,8 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings.| Date | Change | Summary ||---|---|---|+| 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |+| 2026-10-13 | minor | CMYK Hue/Saturation (not Colorize) and Color Balance work on C, M and Y as inverted RGB with black kept, on the inks for display, export and destructive edits; cmyk8/16 hue-saturation 100% → 0.4–0.7% bad pixels, color-balance 74% → 25% || 2026-10-13 | minor | CMYK Posterize works on the stored values (1 − ink), as Photoshop does: psd-tools posterize_cmyk passes (13.8 % → 0 of pixels off on the ink path); psd-tools floor → 242 of 309 || 2026-10-13 | minor | CMYK documents whose layers are plain raster layers plus Invert, Posterize, Threshold, Brightness/Contrast, Levels or Curves layers composite on their own inks for display, export and flattening: the cmyk8/16 oracles for those seven adjustments pass; Photoshop-oracle floor 151 → 165 of 258 || 2026-10-13 | minor | CMYK Threshold compares the Rec. 601 luma of the inks' plain complement, as Photoshop does (every pixel of cmyk8/16 threshold-128.psd); oracle bad pixels 1.6% → 0.2% |diff --git a/docs/gaps.md b/docs/gaps.mdindex 7c6722e60..3c9561574 100644--- a/docs/gaps.md+++ b/docs/gaps.md@@ -1,6 +1,6 @@# Where PhotoCraft falls short of Photoshop-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impacton the way to beta. This is the work list agents pick from: take the highest-ranked entry that@@ -43,7 +43,7 @@ what an agent can't finish alone.- **Missing:** PSDs we write are not always accepted by Photoshop, and Photoshop-authored filesdon't always render as Photoshop renders them.- **Evidence:** corpus floors (`crates/io/tests/corpus.rs`, scorecard): Photoshop-authored- oracles 147/258 (57%; Gradient Map luminosity 2026-10-13; CMYK Invert, Posterize and Threshold on the inks 2026-10-12), io corpus 146/170 (86%), psd-tools 236/309 (76%); round trips ~100%+ oracles 185/258 (72%; CMYK and Lab adjustment layers, 32-bit unclipped adjustments, Levels, Threshold, Posterize and mask feathers 2026-10-13; Gradient Map luminosity 2026-10-13; CMYK Invert, Posterize and Threshold on the inks 2026-10-12), io corpus 148/170 (87%), psd-tools 249/309 (81%); round trips ~100%within the corpus. Smart-filter re-render matches 5/30. User reports: a PSD with text layersre-saved unmodified would not reopen (#2374, closed 2026-10-10), Photoshop 26.6 cannot reopen our files (#1281), "PSD notopening in Photoshop" (#2469), a CS2-era smart object unavailable (#2465, fixed 2026-10-12), PSB smart object@@ -262,6 +262,8 @@ what an agent can't finish alone.| Date | Change | Summary ||---|---|---|+| 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |+| 2026-10-13 | minor | G1: CMYK Hue/Saturation and Color Balance work on C, M and Y as inverted RGB with black kept, as Photoshop does; cmyk hue-saturation 100% → 0.4–0.7% bad pixels, color-balance 74% → 25%; floor unchanged || 2026-10-13 | minor | G1: CMYK Posterize works on the stored values (1 − ink); psd-tools posterize_cmyk passes; psd-tools floor → 242 of 309 || 2026-10-13 | minor | G1: CMYK stacks with Invert, Posterize, Threshold, Brightness/Contrast, Levels or Curves layers composite on the document's own inks (14 CMYK oracles pass); Photoshop-oracle floor 151 → 165 of 258 || 2026-10-13 | minor | CMYK Threshold compares the Rec. 601 luma of the inks' plain complement, as Photoshop does (every pixel of cmyk8/16 threshold-128.psd); oracle bad pixels 1.6% → 0.2% |diff --git a/docs/scorecard.md b/docs/scorecard.mdindex d88548f30..4b1022658 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -7,7 +7,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| Area | Done | Partial | Missing | Key numbers ||---|---:|---:|---:|---|| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |-| [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 242/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 165/256, round trip ≥ 258/256 |+| [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 185/256, round trip ≥ 258/256 || [Tools](#tools) | 32 | 11 | 0 | || [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 161 (target 0) || [Type](#type) | 4 | 3 | 2 | |@@ -92,9 +92,9 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t| Corpus | Directory | Files | Oracle pass floor | Round-trip floor ||---|---|---:|---:|---:|-| io corpus | `corpus/psd` | 170 | 146 | 169 |-| psd-tools corpus | `corpus/psd-tools` | 309 | 242 | 308 |-| photoshop oracles | `corpus/photoshop` | 256 | 165 | 258 |+| io corpus | `corpus/psd` | 170 | 148 | 169 |+| psd-tools corpus | `corpus/psd-tools` | 309 | 249 | 308 |+| photoshop oracles | `corpus/photoshop` | 256 | 185 | 258 || Id | Target | Status | Issue | Note ||---|---|---|---|---|