use crate::utils::{RgbaOutputFormat}; use anyhow::Error; use clap::Parser; use image::{GenericImage}; use serde::{Deserialize, Serialize}; /// Limit the number of colours by quantity or threshold #[derive(Debug, Clone, Parser, Serialize, Deserialize)] #[clap(author, version = "0.3.0")] pub struct Reduce { /// The path to the image file #[serde(default)] pub input: String, /// The path to write the recoloured image #[serde(default)] pub output: String, /// The number of colours to use for quantizing #[clap(short, long)] pub colours: Option<u32>, /// The colour difference threshold to limit colour reduction #[clap(short, long)] pub threshold: Option<f32>, } impl Reduce { pub fn run<T: GenericImage>(&self, _image: &T) -> anyhow::Result<RgbaOutputFormat> { Err(Error::msg("Reduce is not implemented")) // TODO: Reduce impl // let mut palette = Palette::extract_from(image)?; // // let similarity = HashMap::with_capacity(palette.len()); // let mapping: ColourMapping = ColourMapping::new(); // // while !palette.is_empty() { // let next = palette.pop(); // } // // Ok(RgbaImage::from_fn(image.width(), image.height(), |x, y| { // Rgba::from([0, 0, 0, 0]) // })) } }