Merge PR #7959: Actions: Emboss saves to and loads from .atn as Photoshop's Embs step (#7946)

This commit is contained in:
aiongg committed 2026-10-21 21:55:49 +00:00
commit 97a1a67f38
2 files changed
+31

No files matched your search

+8
View File
@@ -2829,6 +2829,14 @@ const EVENTS: &[Event] = &[
ev!("Mdn ", "median", "Median", "filter.noise.median", &[F("Rds ", "radius", Kind::Px)]),
ev!("DstS", "dustAndScratches", "Dust & Scratches", "filter.noise.dustAndScratches", &[F("Rds ", "radius", Kind::Px), F("Thsh", "threshold", Kind::Long)]),
ev!("Dspc", "despeckle", "Despeckle", "filter.noise.despeckle", &[]),
// Photoshop records Emboss's angle, height and amount as plain integers (#7946).
ev!(
"Embs",
"emboss",
"Emboss",
"filter.stylize.emboss",
&[F("Angl", "angle", Kind::Long), F("Hght", "height", Kind::Long), F("Amnt", "amount", Kind::Long)]
),
ev!("MtnB", "motionBlur", "Motion Blur", "filter.blur.motionBlur", &[F("Angl", "angle", Kind::Ang), F("Dstn", "distance", Kind::Px)]),
ev!("", "boxblur", "Box Blur", "filter.blur.boxBlur", &[F("Rds ", "radius", Kind::Px)]),
ev!("", "surfaceBlur", "Surface Blur", "filter.blur.surfaceBlur", &[F("Rds ", "radius", Kind::Px), F("Thsh", "threshold", Kind::Long)]),
+23
View File
@@ -250,6 +250,7 @@ fn every_mapped_command_exports_and_imports_back() {
("filter.sharpen.unsharpMask", json!({"amount": 120, "radius": 1.5, "threshold": 3})),
("filter.noise.addNoise", json!({"amount": 12.5, "distribution": "gaussian", "monochromatic": true, "seed": 7})),
("filter.noise.median", json!({"radius": 2})),
("filter.stylize.emboss", json!({"angle": 135, "height": 3, "amount": 100})),
("filter.blur.motionBlur", json!({"angle": 45, "distance": 20})),
("filter.blur.smartBlur", json!({"radius": 2.5, "threshold": 40, "quality": "medium", "mode": "overlayEdge"})),
("filter.other.offset", json!({"horizontal": 10, "vertical": -5, "undefinedAreas": "wrap"})),
@@ -1500,6 +1501,28 @@ fn arbitrary_rotation_keeps_interpolation_through_atn() {
}
}
/// Filter › Stylize › Emboss saves as Photoshop's `Embs` event with integer `Angl`, `Hght` and
/// `Amnt`, and loads back as the same step (#7946: it was skipped, so a portable action lost it).
#[test]
fn emboss_saves_as_photoshops_event_and_loads_back() {
let mut s = Session::new();
let params = json!({"angle": 130, "height": 1, "amount": 70});
s.actions.list.push(Action::new("Pore", vec![("filter.stylize.emboss".into(), params.clone())]));
let r = s.execute("actions.save", json!({"action": "Pore"})).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 step = &file.actions[0].items[0];
assert_eq!(step.event.id(), "Embs");
let d = step.descriptor.as_ref().unwrap();
for (key, want) in [("Angl", 130), ("Hght", 1), ("Amnt", 70)] {
assert_eq!(d.get(key), Some(&D::Integer(want)), "{key}");
}
let mut t = Session::new();
t.execute("actions.load", json!({"data": b64(&saved)})).unwrap();
assert_eq!(t.actions.list[0].steps, vec![("filter.stylize.emboss".to_string(), params)]);
}
/// A filter recorded against a layer mask must not export as a plain filter that edits the
/// layer's pixels on replay: Photoshop's descriptor has no field for PhotoCraft's `target`.
#[test]