This commit is contained in:
2024-06-29 22:49:37 +02:00
parent 948a8f3610
commit 4e914db386
8 changed files with 465 additions and 74 deletions

18
src/libs/image.rs Normal file
View File

@@ -0,0 +1,18 @@
use image;
use image::GenericImageView;
pub fn load_image(file_name: &str) -> image::DynamicImage {
let img = image::open(file_name).expect("File not found!");
println!("Image loaded: {file_name}");
img
}
pub fn print_size(img: &image::DynamicImage) {
let (width, height) = img.dimensions();
println!("Image dimensions: {width}x{height}");
}
pub fn resize_image(img: &image::DynamicImage, nwidth: usize, nheight: usize) -> image::DynamicImage {
img.resize(nwidth as u32, nheight as u32, image::imageops::FilterType::Lanczos3)
}