Skip to content

Commit

Permalink
Merge pull request #49 from PoSayDone/fix/image-resize
Browse files Browse the repository at this point in the history
Added image resizing
  • Loading branch information
InioX authored Feb 2, 2024
2 parents 702e912 + 6f2ff53 commit ab38e92
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 ab38e92

Please sign in to comment.