This crate is a high level library using MagickWand (ImageMagick) for image identification, conversion, interlacing and high quality resizing.
Identify an image.
```rust 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();
asserteq!(4592, id.resolution.width); asserteq!(2584, id.resolution.height); asserteq!("JPEG", id.format); asserteq!(InterlaceType::NoInterlace, id.interlace); ```
Convert an image to a PNG image and also resize it.
```rust use std::path::Path;
use imageconvert::{ImageResource, PNGConfig, topng};
let sourceimagepath = Path::new("tests/data/P1060382.JPG");
let targetimagepath = Path::join(sourceimagepath.parent().unwrap(), "P1060382_output.png");
let mut config = PNGConfig::new();
config.width = 1920;
let input = ImageResource::frompath(sourceimage_path);
let mut output = ImageResource::frompath(targetimage_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
https://docs.rs/image-convert