From 00d5a71313ab611b606b8e2d977a355d7fa5629f Mon Sep 17 00:00:00 2001 From: Arian100 Date: Thu, 22 Oct 2026 13:41:29 +0200 Subject: [PATCH 1/2] fix(atn): export Black & White adjustment layers with Photoshop's BanW class (#8481) A Make step for a Black & White adjustment layer was written with the type class `BlnW`, which Photoshop refuses ("The command Make is not currently available"), and Photoshop's own `BanW` Make imported as an unsupported step. Export and import now use `BanW`; `BlnW` stays accepted on import so actions saved by older PhotoCraft builds still load. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/atn_cmds.rs | 14 +++++++++--- crates/engine/src/atn_cmds/tests.rs | 34 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index 3be9ee217a..6b2c37df88 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -874,14 +874,22 @@ const ADJUSTMENTS: &[Adjustment] = &[ adj_fields!("Vbrn", "vibrance", &[F("vibrance", "vibrance", Kind::Long), F("Strt", "saturation", Kind::Long)]), adj_fields!("Exps", "exposure", &[F("Exps", "exposure", Kind::Dbl), F("Ofst", "offset", Kind::Dbl), F("gammaCorrection", "gamma", Kind::Dbl)]), Adjustment { class: "PhtF", suffix: "photoFilter", from: |d| fields_from(d, PHOTO_FILTER_FIELDS).map(Value::Object), to: photo_filter_to }, - adj_fields!("BlnW", "blackWhite", BW), + adj_fields!("BanW", "blackWhite", BW), Adjustment { class: "ChnM", suffix: "channelMixer", from: channel_mixer_from, to: channel_mixer_to }, Adjustment { class: "SlcC", suffix: "selectiveColor", from: selective_from, to: selective_to }, Adjustment { class: "GdMp", suffix: "gradientMap", from: gradient_map_from, to: gradient_map_to }, ]; +/// Adjustment classes PhotoCraft once exported, with the class Photoshop uses. Measured in +/// Photoshop (#8481): a Make whose Black & White type is `BlnW` fails ("the command Make is not +/// currently available"), `BanW` runs. Import keeps accepting them so actions saved before still +/// load; export never writes them. +const LEGACY_CLASSES: &[(&str, &str)] = &[("BlnW", "BanW")]; + fn adjustment_by_class(c: &str) -> Option<&'static Adjustment> { - ADJUSTMENTS.iter().find(|a| a.class.trim_end() == c.trim_end()) + let c = c.trim_end(); + let c = LEGACY_CLASSES.iter().find(|(old, _)| *old == c).map_or(c, |(_, class)| class); + ADJUSTMENTS.iter().find(|a| a.class.trim_end() == c) } const PHOTO_FILTER_FIELDS: &[F] = &[F("Clr ", "color", Kind::Color), F("Dnst", "density", Kind::Long), F("PrsL", "preserveLuminosity", Kind::Bool)]; @@ -3105,7 +3113,7 @@ const EVENTS: &[Event] = &[ adjustment_event!("Vbrn", "Vbrn", "vibrance", "Vibrance"), adjustment_event!("Exps", "Exps", "exposure", "Exposure"), adjustment_event!("PhtF", "PhtF", "photoFilter", "Photo Filter"), - adjustment_event!("", "BlnW", "blackAndWhite", "Black & White", "image.adjustments.blackWhite"), + adjustment_event!("", "BanW", "blackAndWhite", "Black & White", "image.adjustments.blackWhite"), adjustment_event!("ChnM", "ChnM", "channelMixer", "Channel Mixer"), adjustment_event!("GdMp", "GdMp", "gradientMapEvent", "Gradient Map", "image.adjustments.gradientMap"), adjustment_event!("SlcC", "SlcC", "selectiveColor", "Selective Color"), diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index e8595086ac..e5d2583173 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1444,6 +1444,40 @@ fn events_photoshop_only_runs_by_name_export_by_name_and_old_codes_still_import( } } +/// A Black & White adjustment layer saves with Photoshop's `BanW` class (#8481): measured in +/// Photoshop, a Make whose type is `BlnW` is refused. Photoshop's own `BanW` Make loads, and so +/// does the `BlnW` one PhotoCraft wrote before. +#[test] +fn black_white_adjustment_layer_saves_as_photoshops_class_and_old_class_still_imports() { + let id = "layer.newAdjustmentLayer.blackWhite"; + let params = json!({"reds": 17, "yellows": 83, "greens": -12, "cyans": 107, "blues": 51, "magentas": 133, "tint": true, "tintColor": "#c08040"}); + let mut s = Session::new(); + s.actions.list.push(Action::new("BW", vec![(id.into(), params.clone())])); + let r = s.execute("actions.save", json!({"action": "BW"})).unwrap(); + assert_eq!(r["skipped"], json!([])); + let saved = photocraft_paint::tile::b64_decode(r["data"].as_str().unwrap()).unwrap(); + let file = atn::parse(&saved).unwrap(); + let make = file.actions[0].items[0].descriptor.as_ref().unwrap(); + let kind = get_obj(make, "Usng").and_then(|u| get_obj(u, "Type")).unwrap(); + assert_eq!(trimmed(&kind.class_id), "BanW"); + let mut t = Session::new(); + let r = t.execute("actions.load", json!({"data": b64(&saved)})).unwrap(); + assert_eq!(r["unsupported"], json!([]), "{r}"); + assert_eq!(t.actions.list[0].steps, vec![(id.to_string(), params)]); + + // Photoshop's minimal Make (no settings) and the old PhotoCraft class both load; near misses + // stay Photoshop steps. + let make = |class: &str| { + let using = desc("AdjL").with("Type", D::Descriptor(desc(class))); + item("Mk ", "Make", Some(desc("null").with("null", class_ref("AdjL")).with("Usng", D::Descriptor(using)))) + }; + let data = set_of("S", vec![("A", ["BanW", "BlnW", "BANW", "BlnWx"].into_iter().map(make).collect())]); + let mut t = Session::new(); + let r = t.execute("actions.load", json!({"data": data})).unwrap(); + let steps: Vec<&str> = t.actions.list[0].steps.iter().map(|(id, _)| id.as_str()).collect(); + assert_eq!(steps, [id, id, PHOTOSHOP_STEP, PHOTOSHOP_STEP], "{r}"); +} + /// Smart Blur's quality uses Photoshop's `SmBQ` codes (`SBQL`/`SBQM`/`SBQH`): measured in /// Photoshop, the old `Hgh `/`Mdm `/`Low ` play back as its fallback quality. Old codes still read. #[test] From 51cd9e1e8c8def54342dcd5119e920c18e386e0d Mon Sep 17 00:00:00 2001 From: Arian100 Date: Thu, 22 Oct 2026 17:08:54 +0200 Subject: [PATCH 2/2] test(atn): check an old BlnW Make keeps its settings; document adjustment_by_class Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/atn_cmds.rs | 1 + crates/engine/src/atn_cmds/tests.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index 6b2c37df88..e9e199e896 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -886,6 +886,7 @@ const ADJUSTMENTS: &[Adjustment] = &[ /// load; export never writes them. const LEGACY_CLASSES: &[(&str, &str)] = &[("BlnW", "BanW")]; +/// The adjustment with Photoshop class `c`, or the one an old PhotoCraft class stands for. fn adjustment_by_class(c: &str) -> Option<&'static Adjustment> { let c = c.trim_end(); let c = LEGACY_CLASSES.iter().find(|(old, _)| *old == c).map_or(c, |(_, class)| class); diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index e5d2583173..2844a140f8 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1465,10 +1465,11 @@ fn black_white_adjustment_layer_saves_as_photoshops_class_and_old_class_still_im assert_eq!(r["unsupported"], json!([]), "{r}"); assert_eq!(t.actions.list[0].steps, vec![(id.to_string(), params)]); - // Photoshop's minimal Make (no settings) and the old PhotoCraft class both load; near misses - // stay Photoshop steps. + // Photoshop's minimal Make (no settings) and an old PhotoCraft Make with a setting both load, + // the setting kept; near misses stay Photoshop steps. let make = |class: &str| { - let using = desc("AdjL").with("Type", D::Descriptor(desc(class))); + let kind = if class == "BlnW" { desc(class).with("Rd ", long(17.0)) } else { desc(class) }; + let using = desc("AdjL").with("Type", D::Descriptor(kind)); item("Mk ", "Make", Some(desc("null").with("null", class_ref("AdjL")).with("Usng", D::Descriptor(using)))) }; let data = set_of("S", vec![("A", ["BanW", "BlnW", "BANW", "BlnWx"].into_iter().map(make).collect())]); @@ -1476,6 +1477,7 @@ fn black_white_adjustment_layer_saves_as_photoshops_class_and_old_class_still_im let r = t.execute("actions.load", json!({"data": data})).unwrap(); let steps: Vec<&str> = t.actions.list[0].steps.iter().map(|(id, _)| id.as_str()).collect(); assert_eq!(steps, [id, id, PHOTOSHOP_STEP, PHOTOSHOP_STEP], "{r}"); + assert_eq!(t.actions.list[0].steps[1].1["reds"], 17, "{r}"); } /// Smart Blur's quality uses Photoshop's `SmBQ` codes (`SBQL`/`SBQM`/`SBQH`): measured in