Skip to content

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

Merge PR #6299: PSD: Surface Blur, Smart Blur and Radial Blur smart filters open and save like Photoshop (#6298)

aiongg8564c7486100
diff --cc crates/io/src/smart_map.rs
index 91ea43d4e,b33b5f518..068e8b3a0
--- a/crates/io/src/smart_map.rs
+++ b/crates/io/src/smart_map.rs
@@@ -540,58 -375,11 +579,58 @@@ fn known_params(class: &str, f: Option<
}),
("RdlB", Some(f)) if only_keys(f, &["Amnt", "BlrM", "BlrQ"]) => json!({
"amount": int_in(f, "Amnt", 1, 100)?,
- "method": enum_name(f, "BlrM", &RADIAL_METHOD)?,
- "quality": enum_name(f, "BlrQ", &RADIAL_QUALITY)?,
+ "method": enum_name(f, "BlrM", "BlrM", &RADIAL_METHOD)?,
+ "quality": enum_name(f, "BlrQ", "BlrQ", &RADIAL_QUALITY)?,
}),
("Msc ", Some(f)) => json!({"cellSize": px(f, "ClSz")?}),
+ ("Mztn", Some(f)) => {
+ let t = enum_of(f, "MztT")?;
+ json!({"type": MEZZOTINT_TYPES.iter().find(|(c, _)| t == &c[..])?.1})
+ }
+ ("ClrH", Some(f)) => color_halftone_params(f)?,
("Embs", Some(f)) => json!({"angle": int(f, "Angl")?, "height": int(f, "Hght")?, "amount": int(f, "Amnt")?}),
+ (SMART_SHARPEN, Some(f)) => smart_sharpen_params(f)?,
+ ("DstS", Some(f)) => {
+ if f.items.iter().any(|(k, _)| !k.is("Rds ") && !k.is("Thsh")) {
+ return None;
+ }
+ json!({"radius": int_in(f, "Rds ", 1, 500)?, "threshold": int_in(f, "Thsh", 0, 255)?})
+ }
+ ("Dfs ", Some(f)) => json!({"mode": enum_from(f, "Md ", "DfsM", &DIFFUSE_MODES)?}),
+ ("TrcC", Some(f)) => json!({"level": int_in(f, "Lvl ", 0, 255)?, "edge": enum_from(f, "Edg ", "CntE", &TRACE_EDGES)?}),
+ ("Crst", Some(f)) => json!({"cellSize": int_in(f, "ClSz", CELL_SIZE.0, CELL_SIZE.1)?}),
+ ("Pntl", Some(f)) => {
+ let mut p = json!({"cellSize": int_in(f, "ClSz", CELL_SIZE.0, CELL_SIZE.1)?});
+ // Pointillize paints the gaps in the background colour the entry carries.
+ if item.get("BckC").is_some() {
+ p["background"] = get_desc(item, "BckC").and_then(rgbc_colour)?;
+ }
+ p
+ }
+ ("Wnd ", Some(f)) => json!({
+ "method": enum_from(f, "WndM", "WndM", &WIND_METHODS)?,
+ "direction": enum_from(f, "Drct", "Drct", &WIND_DIRECTIONS)?,
+ }),
+ ("Extr", Some(f)) => json!({
+ "type": enum_from(f, "ExtT", "ExtT", &EXTRUDE_TYPES)?,
+ "size": int_in(f, "ExtS", EXTRUDE_SIZE.0, EXTRUDE_SIZE.1)?,
+ "depth": int_in(f, "ExtD", EXTRUDE_DEPTH.0, EXTRUDE_DEPTH.1)?,
+ "depthMode": enum_from(f, "ExtR", "ExtR", &EXTRUDE_DEPTHS)?,
+ "solidFrontFaces": bool_at(f, "ExtF")?,
+ "maskIncompleteBlocks": bool_at(f, "ExtM")?,
+ }),
+ ("Tls ", Some(f)) => tiles_params(f, item)?,
+ ("Ofst", Some(f)) => {
+ let fill = OFFSET_FILL.iter().find(|(psd, _)| enum_of(f, "Fl ") == Some(psd.as_bytes()))?.1;
+ json!({"horizontal": int(f, "Hrzn")?, "vertical": int(f, "Vrtc")?, "undefinedAreas": fill})
+ }
+ ("Cstm", Some(f)) => custom_params(f)?,
+ ("LnsF", Some(f)) => {
+ let centre = get_desc(f, "FlrC")?;
+ let lens = enum_of(f, "Lns ")?;
+ let lens = LENSES.iter().find(|(c, _)| lens == &c[..])?.1;
+ json!({"brightness": int(f, "Brgh")?, "centerX": px(centre, "Hrzn")?, "centerY": px(centre, "Vrtc")?, "lens": lens})
+ }
("Lvls", Some(f)) => levels_params(f)?,
("Crvs", Some(f)) => curves_params(f)?,
_ => return None,