Skip to content

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

Merge PR #7030: Lens Correction: smart filters keep the exact focal length (#7029)

aiongg954a7560efda
diff --cc crates/engine/src/lens_cmds.rs
index ba088c708,9546731b7..8f92637fd
--- a/crates/engine/src/lens_cmds.rs
+++ b/crates/engine/src/lens_cmds.rs
@@@ -62,16 -62,10 +62,10 @@@ pub fn lens_params(cmd: &str, p: &Value
"edgeExtension" | "extension" => EdgeMode::Extension,
"black" => EdgeMode::Color([0.0, 0.0, 0.0, 1.0]),
"white" => EdgeMode::Color([1.0, 1.0, 1.0, 1.0]),
- "background" | "color" => EdgeMode::Color(crate::commands::color_param(p, "edgeColor", [0.0, 0.0, 0.0, 1.0])),
+ "background" | "color" => EdgeMode::Color(crate::commands::color_param(cmd, p, "edgeColor", [0.0, 0.0, 0.0, 1.0])?),
other => return Err(bad(cmd, format!("unknown edge `{other}` (transparency|edgeExtension|black|white|color)"))),
};
- let focal = num(p, "focalLength", 0.0);
- lc.profile = match p.get("profile").and_then(Value::as_str).unwrap_or("none") {
- "none" | "" => None,
- "generic" => Some(lens::generic_profile(if focal > 0.0 { focal } else { 50.0 })),
- "auto" => info.and_then(|i| i.focal_length_35mm.or(i.focal_length)).or((focal > 0.0).then_some(focal)).map(lens::generic_profile),
- other => return Err(bad(cmd, format!("unknown profile `{other}` (none|auto|generic)"))),
- };
+ lc.profile = profile_focal(cmd, p, info)?.map(lens::generic_profile);
if let Some(Value::Array(line)) = p.get("straighten") {
let pt = |v: &Value| -> Option<[f64; 2]> { Some([v.get(0)?.as_f64()?, v.get(1)?.as_f64()?]) };
let (Some(a), Some(b)) = (line.first().and_then(pt), line.get(1).and_then(pt)) else {