#image #image-processing

image2

A simple image processing library

16 releases (8 breaking)

✓ Uses Rust 2018 edition

0.10.0 Feb 12, 2019
0.8.0 Jan 6, 2019
0.5.2 Dec 30, 2018
0.4.0 Nov 11, 2018

#67 in Images

Download history 13/week @ 2019-02-12 21/week @ 2019-02-19 38/week @ 2019-02-26 2/week @ 2019-03-05 3/week @ 2019-03-12 24/week @ 2019-03-19 145/week @ 2019-03-26 16/week @ 2019-04-02 2/week @ 2019-04-09 1/week @ 2019-04-16 21/week @ 2019-04-23 2/week @ 2019-04-30 16/week @ 2019-05-07 26/week @ 2019-05-14 69/week @ 2019-05-21

130 downloads per month

ISC license

413KB
2.5K SLoC

image2

A Rust library focused on generic image processing for a wide range of datatypes. stb_image is used as the default encoder/decoder and supports the following formats:

  • JPEG [RW]
  • PNG [RW]
  • TGA [RW]
  • BMP [RW]
  • PSD [R]
  • GIF [R]
  • HDR [RW]

Additional formats are provided by:

Optional crate features

  • v4l
    • Enables support for webcam capture on Linux
  • ser
    • Automatically derive serde traits for images and many other datatyes
  • parallel
    • Uses rayon to iterate over pixels in parallel (enabled by default)

lib.rs:

image2 is an image processing crate with a focus on ease-of-use, support for a wide range of datatypes and composable operations.

Getting started:

use image2::{
   ImageBuf,
   Rgb, Gray,
   Type,
   io,
   Filter,
   filter::ToGrayscale
};

fn main() {
   // Read an image using the default JPEG decoder (stb_image)
   let image: ImageBuf<f64, Rgb> = io::read("test/test.jpg").unwrap();

   // Setup a filter
   let filter = ToGrayscale.and_then(|f| {
       f64::max_f() - f
   });

   // Create an output image
   let mut output: ImageBuf<f64, Gray> = ImageBuf::new_like_with_color::<Gray>(&image);

   // Execute the filter
   filter.eval(&mut output, &[&image]);

   // Save the image using the default PNG encoder (stb_image)
   io::write("example.png", &output).unwrap();
}

Dependencies

~2MB
~43K SLoC