项目作者: magiclen

项目描述 :
A high level library for image identification, conversion, interlacing and high quality resizing.
高级语言: Rust
项目地址: git://github.com/magiclen/image-convert.git
创建时间: 2018-08-13T02:36:50Z
项目社区:https://github.com/magiclen/image-convert

开源协议:MIT License

下载


Image Convert

CI

This crate is a high level library using MagickWand (ImageMagick) for image identification, conversion, interlacing and high quality resizing.

Examples

Identify an image.

  1. use image_convert::{ImageResource, InterlaceType, identify};
  2. let input = ImageResource::from_path("tests/data/P1060382.JPG");
  3. let mut output = None;
  4. let id = identify(&mut output, &input).unwrap();
  5. assert_eq!(4592, id.resolution.width);
  6. assert_eq!(2584, id.resolution.height);
  7. assert_eq!("JPEG", id.format);
  8. assert_eq!(InterlaceType::NoInterlace, id.interlace);

Convert an image to a PNG image and also resize it.

  1. use std::path::Path;
  2. use image_convert::{ImageResource, PNGConfig, to_png};
  3. let source_image_path = Path::new("tests/data/P1060382.JPG");
  4. let target_image_path = Path::join(source_image_path.parent().unwrap(), "P1060382_output.png");
  5. let mut config = PNGConfig::new();
  6. config.width = 1920;
  7. let input = ImageResource::from_path(source_image_path);
  8. let mut output = ImageResource::from_path(target_image_path);
  9. to_png(&mut output, &input, &config).unwrap();

Supported output formats are BMP, JPG, PNG, GIF, WEBP, ICO, PGM and GrayRaw.

Crates.io

https://crates.io/crates/image-convert

Documentation

https://docs.rs/image-convert

License

MIT