Skip to content
Snippets Groups Projects
reduce.rs 1.19 KiB
Newer Older
Louis's avatar
Louis committed
use anyhow::Error;
use clap::Parser;
Louis's avatar
Louis committed
use image::GenericImage;
Louis's avatar
Louis committed
use serde::{Deserialize, Serialize};
Louis's avatar
Louis committed
use crunch_cli::utils::RgbaOutputFormat;
Louis's avatar
Louis committed

Louis's avatar
Louis committed
/// 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 {
Louis's avatar
Louis committed
	pub fn _run<T: GenericImage>(&self, _image: &T) -> anyhow::Result<RgbaOutputFormat> {
Louis's avatar
Louis committed
		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])
		// }))
	}
}