#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Dither {
None,
Bayer,
FloydSteinberg,
}
impl Dither {
pub fn parse(s: &str) -> Result<Dither, String> {
match s.to_ascii_lowercase().as_str() {
"none" => Ok(Dither::None),
"floyd_steinberg" | "floyd-steinberg" | "floydsteinberg" | "fs" => {
Ok(Dither::FloydSteinberg)
}
"bayer" | "ordered" | "o8x8" => Ok(Dither::Bayer),
other => Err(format!(
"convert: -dither: unknown strategy '{other}' (expected 'none', 'bayer', or 'floyd_steinberg')"
)),
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Op {
Resize { width: u32, height: u32, bang: bool },
Blur { radius: u32, sigma: f32 },
Edge { radius: u32 },
Colors { count: u32, dither: Dither },
Format(String),
Quality(u32),
Strip,
}
#[derive(Clone, Debug)]
pub struct ConvertPlan {
pub input: String,
pub ops: Vec<Op>,
pub output: String,
}