apply luma-only effects

This commit is contained in:
Waveplate 2024-12-15 07:33:48 -08:00
parent bb0ba0e990
commit 7cadbf8aad

View File

@ -5,36 +5,37 @@ mod effects;
use reqwest;
use url::Url;
use photon_rs::PhotonImage;
use std::{error::Error, io::Cursor, process::exit};
#[tokio::main]
async fn main() {
let args = args::parse_args();
match load_image_from_url_or_path(args.image.as_str()).await {
Ok(mut image) => {
image = effects::apply_effects(
&args,
image,
);
Ok(image) => {
let image_luma = effects::apply_luma_effects(&args, image.clone());
let image_chroma = effects::apply_effects(&args, image.clone());
let canvas = draw::AnsiImage::new(image);
let canvas_luma = draw::AnsiImage::new(image_luma.clone());
let canvas_chroma = draw::AnsiImage::new(image_chroma.clone());
match (args.irc, args.ansi, args.ansi24, args.qb) {
(true, _, _, true) => println!("{}", draw::irc_draw_qb(canvas, &args).as_str()),
(true, _, _, false) => println!("{}", draw::irc_draw(canvas, &args).as_str()),
(_, true, _, true) => println!("{}", draw::ansi_draw_8bit_qb(canvas, &args).as_str()),
(_, true, _, false) => println!("{}", draw::ansi_draw_8bit(canvas, &args).as_str()),
(_, _, true, true) => println!("{}", draw::ansi_draw_24bit_qb(canvas).as_str()),
(_, _, true, false) => println!("{}", draw::ansi_draw_24bit(canvas).as_str()),
(_, _, _, true) => println!("{}", draw::irc_draw_qb(canvas, &args).as_str()),
_ => println!("{}", draw::irc_draw(canvas, &args).as_str()),
match (args.irc, args.ansi, args.ansi24, args.qb, args.braille) {
(true, _, _, true, false) => println!("{}", draw::irc_draw_qb(&canvas_chroma, &args)),
(true, _, _, false, false) => println!("{}", draw::irc_draw(&canvas_chroma, &args)),
(true, _, _, _, true) => println!("{}", draw::irc_draw_braille(&canvas_luma, &canvas_chroma, &args)),
(_, true, _, true, false) => println!("{}", draw::ansi_draw_8bit_qb(&canvas_chroma, &args)),
(_, true, _, false, false) => println!("{}", draw::ansi_draw_8bit(&canvas_chroma, &args)),
(_, true, _, _, true) => println!("{}", draw::ansi_draw_braille_8bit(&canvas_luma, &canvas_chroma, &args)),
(_, _, true, true, false) => println!("{}", draw::ansi_draw_24bit_qb(&canvas_chroma)),
(_, _, true, false, false) => println!("{}", draw::ansi_draw_24bit(&canvas_chroma)),
(_, _, true, _, true) => println!("{}", draw::ansi_draw_braille_24bit(&canvas_luma, &canvas_chroma, &args)),
(_, _, _, true, false) => println!("{}", draw::irc_draw_qb(&canvas_chroma, &args)),
(_, _, _, _, true) => println!("{}", draw::irc_draw_braille(&canvas_luma, &canvas_chroma, &args)),
_ => println!("{}", draw::irc_draw(&canvas_chroma, &args)),
}
}
}
Err(e) => {
eprintln!("Error: {}", e);
exit(1);
@ -47,7 +48,6 @@ async fn load_image_from_url_or_path(image: &str) -> Result<PhotonImage, Box<dyn
Ok(url) => {
let response = reqwest::get(url).await?;
let bytes = response.bytes().await?;
let image_data = Cursor::new(bytes);
match photon_rs::native::open_image_from_bytes(image_data.into_inner().as_ref()) {
Ok(image) => Ok(image),
@ -62,4 +62,3 @@ async fn load_image_from_url_or_path(image: &str) -> Result<PhotonImage, Box<dyn
}
}
}