Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #8344: Actions: Photo Filter saves to .atn under the name the reference app runs (#8301)

aiongg46adea7eb831
diff --cc crates/engine/src/atn_cmds.rs
index 4a4575ffa,06f2cfa4e..47318134f
--- a/crates/engine/src/atn_cmds.rs
+++ b/crates/engine/src/atn_cmds.rs
@@@ -845,17 -787,16 +845,18 @@@ fn gradient_map_to(p: &Value) -> Option
.with("Intr", D::Double(4096.0))
.with("Clrs", D::List(stops?))
.with("Trns", transparency);
- Some(
- desc("GdMp")
- .with("Grad", D::Descriptor(grad))
- .with("Rvrs", D::Boolean(jbool(p, "reverse").unwrap_or(false)))
- .with("Dthr", D::Boolean(jbool(p, "dither").unwrap_or(false))),
- )
+ let mut d = desc("GdMp").with("Grad", D::Descriptor(grad));
+ if let Some(r) = jbool(p, "reverse") {
+ d = d.with("Rvrs", D::Boolean(r));
+ }
+ if let Some(dd) = jbool(p, "dither") {
+ d = d.with("Dthr", D::Boolean(dd));
+ }
+ Some(d)
}
- /// An adjustment: its Photoshop class (also the direct event's code), the command suffix (`image.adjustments.<suffix>`, `layer.newAdjustmentLayer.<suffix>`), and
+ /// An adjustment: its Photoshop class (usually also the direct event's code; Black & White and
+ /// Photo Filter run by name), the command suffix (`image.adjustments.<suffix>`, `layer.newAdjustmentLayer.<suffix>`), and
/// the converters between the adjustment descriptor and the command params.
struct Adjustment {
class: &'static str,
@@@ -3141,10 -2773,31 +3142,11 @@@ const EVENTS: &[Event] = &
adjustment_event!("ClrB", "ClrB", "colorBalance", "Color Balance"),
adjustment_event!("Vbrn", "Vbrn", "vibrance", "Vibrance"),
adjustment_event!("Exps", "Exps", "exposure", "Exposure"),
- adjustment_event!("PhtF", "PhtF", "photoFilter", "Photo Filter"),
+ // Photoshop runs Photo Filter by name only: `PhtF` is the class, not an event (#8301).
+ adjustment_event!("", "PhtF", "photoFilter", "Photo Filter"),
- Event {
- code: "",
- name: "blackAndWhite",
- label: "Black & White",
- ids: &["image.adjustments.blackWhite"],
- from: |d| match adjustment_by_class("BlnW") {
- Some(a) => adjustment_steps(a, "image.adjustments.", Some(d)),
- None => Mapped::Unsupported { harmless: false },
- },
- to: |_, p| adjustment_by_class("BlnW").and_then(|a| (a.to)(p)),
- },
+ adjustment_event!("", "BlnW", "blackAndWhite", "Black & White", "image.adjustments.blackWhite"),
adjustment_event!("ChnM", "ChnM", "channelMixer", "Channel Mixer"),
- Event {
- code: "GdMp",
- name: "gradientMapEvent",
- label: "Gradient Map",
- ids: &["image.adjustments.gradientMap"],
- from: |d| match adjustment_by_class("GdMp") {
- Some(a) => adjustment_steps(a, "image.adjustments.", Some(d)),
- None => Mapped::Unsupported { harmless: false },
- },
- to: |_, p| adjustment_by_class("GdMp").and_then(|a| (a.to)(p)),
- },
+ adjustment_event!("GdMp", "GdMp", "gradientMapEvent", "Gradient Map", "image.adjustments.gradientMap"),
adjustment_event!("SlcC", "SlcC", "selectiveColor", "Selective Color"),
ev!("Dstt", "desaturate", "Desaturate", "image.adjustments.desaturate", &[]),
ev!("Eqlz", "equalize", "Equalize", "image.adjustments.equalize", &[]),