Crates.io | image-convert |
lib.rs | image-convert |
version | 0.19.0 |
source | src |
created_at | 2019-04-18 09:36:34.275037 |
updated_at | 2024-11-28 08:40:07.270787 |
description | A high level library for image identification, conversion, interlacing and high quality resizing. |
homepage | https://magiclen.org/image-convert |
repository | https://github.com/magiclen/image-convert |
max_upload_size | |
id | 128645 |
size | 61,751 |
This crate is a high level library using MagickWand (ImageMagick) for image identification, conversion, interlacing and high quality resizing.
Identify an image.
use image_convert::{ImageResource, InterlaceType, identify};
let input = ImageResource::from_path("tests/data/P1060382.JPG");
let mut output = None;
let id = identify(&mut output, &input).unwrap();
assert_eq!(4592, id.resolution.width);
assert_eq!(2584, id.resolution.height);
assert_eq!("JPEG", id.format);
assert_eq!(InterlaceType::NoInterlace, id.interlace);
Convert an image to a PNG image and also resize it.
use std::path::Path;
use image_convert::{ImageResource, PNGConfig, to_png};
let source_image_path = Path::new("tests/data/P1060382.JPG");
let target_image_path = Path::join(source_image_path.parent().unwrap(), "P1060382_output.png");
let mut config = PNGConfig::new();
config.width = 1920;
let input = ImageResource::from_path(source_image_path);
let mut output = ImageResource::from_path(target_image_path);
to_png(&mut output, &input, &config).unwrap();
Supported output formats are BMP
, JPG
, PNG
, GIF
, WEBP
, ICO
, PGM
and GrayRaw
.
https://crates.io/crates/image-convert