#image-resizing #resize #file-path #size #applications #craft #dest-folder

img_craft

Utility of Images for General Purpose Application

1 unstable release

0.1.3 Dec 23, 2024
0.1.2 Dec 23, 2024
0.1.1 Dec 22, 2024
0.1.0 Dec 22, 2024

#686 in Images

Download history 307/week @ 2024-12-21 14/week @ 2024-12-28

321 downloads per month

MIT license

12KB
146 lines

img_craft

A versatile crate for effortless image resizing and thumbnail generation, designed for Responsive Web Design (RWD).

Install

cargo add img_crate

Usage

Resize as ext

use img_craft::{
    resize_image_to_multi_sizes,
};

fn main() {
	let file_path = "/home/user1/image1.jpg";
	let dest_folder = "/home/user1/output";
	let out_ext_name
	resize_as_ext(file_path, dest_folder);
}

Resize Image with default sizes

use img_craft::{
    resize_image_to_multi_sizes,
};

fn main() {
	let file_path = "/home/user1/image1.jpg";
	let dest_folder = "/home/user1/output";
	resize_image_to_multi_sizes(file_path, dest_folder);
}

Resize Image with custom sizes

use img_craft::{
	resize_image_to_multi_sizes_custom,
	Size,
};

fn main() {
	let file_path = "/home/user1/image1.jpg";
	let dest_folder = "/home/user1/output";
	let sizes = vec!(
		Size::new(String::from("s"),      480,  720),
		Size::new(String::from("m"),      768, 1024),
		Size::new(String::from("l"),     1024, 1366),
	);
	resize_image_to_multi_sizes_custom(file_path, dest_folder, sizes);
}

Resize Image by code

Code is one of {"xxs", "xs", "s", "m", "l", "xl", "xxl", "ultra"}

Image Size Code Image Width Image Height
xxs 300px 300px
xs 320px 480px
s 480px 720px
m 768px 1024px
l 1024px 1366px
xl 1920px 1080px
xxl 3840px 2160px
ultra 7680px 4320px
use img_craft::{
	resize_image_by_code,
};

fn main() {
	let file_path = "/home/user1/image1.jpg";
	let dest_folder = "/home/user1/output";
	let code = "xs";
	resize_image_by_code(file_path, dest_folder, code);
}

Dependencies

~5MB
~63K SLoC