[][src]Crate raster

Raster

Raster is an image processing lib for Rust.

It provides a simplified API for processing raster images (JPEG, PNG and GIF).

Installation

Add this to your Cargo.toml file:

This example is not tested
[dependencies]

raster = "x.x.x"

Where x are version numbers of the latest version of raster. Eg.: 0.1.0

Then add the raster crate in your main.rs:

This example is not tested
extern crate raster; // In your main rust file

Creating Images

From an image file

This example is not tested
// Create an image from file
let image = raster::open("tests/in/sample.png").unwrap();

Raster will detect the image format based on the file name.

Create a blank image

This example is not tested
use raster::Image; // Include the Image struct

// Create a blank 150x100 image. Defaults to a black background.
let image = Image::blank(150, 100);

Saving Images

Save the opened image file:

// Create an image from file
let image = raster::open("tests/in/sample.png").unwrap();

// Save opened image
raster::save(&image, "tests/out/test_open_save.png").unwrap();

Blending 2 Images

Here are two images blended using the normal mode.

More blending modes and options are available, see the blend API.

Resizing Images

An example of images resized to "fit" in a 200x200 box.

More modes available, see the resize API.

Rotating Images

Images can be rotated both clockwise and counter-clockwise at any arbitrary angle with a custom background color.

And Many More...

More options are available, checkout the modules below.

Re-exports

pub use editor::ResizeMode;
pub use filter::BlurMode;
pub use filter::Orientation;
pub use interpolate::InterpolationMode;
pub use transform::TransformMode;

Modules

compare

A module for comparing images.

editor

A module for common image editing operations.

error

A module for error types.

filter

A module for filtering pixels.

interpolate

A module for interpolating pixels.

transform

A module for 2D transformation.

Structs

Color

A struct for representing and creating color.

Image

A struct for easily representing a raster image.

Enums

BlendMode

Enumeration for blending modes.

ImageFormat

Enumeration of supported raster formats.

PositionMode

Enumeration for different anchor positions.

Functions

open

Create an image from an image file.

save

Save an image to an image file. The image type is detected from the file extension of the file name.

Type Definitions

Histogram

Holds histogram information.