#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

#39 in Images

Download history 29/week @ 2018-11-27 21/week @ 2018-12-04 9/week @ 2018-12-11 51/week @ 2018-12-18 33/week @ 2018-12-25 55/week @ 2019-01-01 36/week @ 2019-01-08 26/week @ 2019-01-15 28/week @ 2019-01-22 6/week @ 2019-01-29 3/week @ 2019-02-05 13/week @ 2019-02-12 21/week @ 2019-02-19 38/week @ 2019-02-26 2/week @ 2019-03-05

102 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
~42K SLoC

  • build build.rs
  • build cc 1.0