more params

This commit is contained in:
2024-07-07 14:42:58 +02:00
parent 274ceb0b83
commit e0f043bb77
3 changed files with 21 additions and 9 deletions

View File

@@ -20,4 +20,10 @@ pub struct Args {
#[arg(long, default_value_t = 2)]
pub pixel: usize,
#[arg(long, default_value_t = false)]
pub noresize: bool,
#[arg(long, default_value_t = false)]
pub matrix: bool,
}

View File

@@ -55,6 +55,10 @@ pub fn to_ascii(img: &image::DynamicImage, args: &args::Args) -> String {
char_pixel = select_dominant_color((red, green, blue), char_pixel);
}
if args.matrix {
char_pixel = char_pixel.bright_green().to_string();
}
ascii_img.push_str(&char_pixel);
}
ascii_img.push('\n');

View File

@@ -6,14 +6,16 @@ fn main() {
let args = libs::args::Args::parse();
let img = libs::image::load_image(&args.image);
let mut img = libs::image::load_image(&args.image);
libs::image::print_size(&img);
let resized_img = libs::image::resize_image(&img, args.width, args.height);
println!("Image resized");
libs::image::print_size(&resized_img);
if !args.noresize {
img = libs::image::resize_image(&img, args.width, args.height);
println!("Image resized");
libs::image::print_size(&img);
}
let ascii_img = libs::ascii::to_ascii(&resized_img, &args);
let ascii_img = libs::ascii::to_ascii(&img, &args);
println!("ASCII image created");
println!("{ascii_img}");