Skip to content

Commit

Permalink
Added image resizing
Browse files Browse the repository at this point in the history
As library says it is crucial to resize image to 128x128 before processing it
  • Loading branch information
PoSayDone committed Feb 1, 2024
1 parent 702e912 commit 6f2ff53
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/util/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::Schemes;
use crate::util::image::fetch_image;

use image::io::Reader as ImageReader;
use image::imageops::{resize, FilterType};

use super::arguments::{ColorFormat, Format, Source};
use super::image::source_color_from_image;
Expand Down Expand Up @@ -164,15 +165,18 @@ pub fn get_source_color(source: &Source) -> Result<[u8; 4], Report> {
.decode()
.expect("failed to decode image")
.into_rgba8();

let img = resize(&img, 128, 128, FilterType::Gaussian);

source_color_from_image(img)?
}
Source::WebImage { url } => {
// test
info!("Fetching image from <d><u>{}</>", url);

let img = fetch_image(url)?;
source_color_from_image(img.into_rgba8())?
let img = fetch_image(url)?.into_rgba8();
let img = resize(&img, 128, 128, FilterType::Gaussian);

source_color_from_image(img)?
}
Source::Color(color) => {
let src: Rgb = match color {
Expand Down

0 comments on commit 6f2ff53

Please sign in to comment.