Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Maintainers: @nwin, @ccgn
An Image Processing Library
This crate provides basic imaging processing functions and methods for converting to and from image formats.
All image processing functions provided operate on types that implement the
GenericImage trait and return an
Add the following to the Cargo.toml in your project:
[dependencies] image = "*"
and import using
extern crate image; //Use image::
2. Supported Image Formats
image provides implementations of common image format encoders and decoders.
2.1 Supported Image Formats
|PNG||All supported color types||Same as decoding|
|JPEG||Baseline JPEG||Baseline JPEG|
|TIFF||Baseline(no fax and packbits support) + LZW||No|
|Webp||Lossy(Luma channel only)||No|
All image format decoders implement the
ImageDecoder trait which provides the following methods:
- dimensions: Return a tuple containing the width and height of the image
- colortype: Return the color type of the image.
- row_len: Returns the length in bytes of one decoded row of the image
- read_scanline: Read one row from the image into buf Returns the row index
- read_image: Decode the entire image and return it as a Vector
- load_rect: Decode a specific region of the image
image provides the following pixel types:
- Rgb: RGB pixel
- Rgba: RGBA pixel
- Luma: Grayscale pixel
- LumaA: Grayscale with alpha
All pixels are parameterised by their component type.
A trait that provides functions for manipulating images, parameterised over the image's pixel type.
4.2 Representation of Images
image provides two main ways of representing image data:
An image parametarised by its Pixel types, represented by a width and height and a vector of pixels. It provides direct access to its pixels and implements the
extern crate image; use ; //Construct a new ImageBuffer with the specified width and height. let img = new; //Construct a new by repeated calls to the supplied closure. let img = from_fn; //Obtain the image's width and height let = img.dimensions; //Access the pixel at coordinate (100, 100) let pixel = img; //or using the ```get_pixel``` method from the ```GenericImage``` trait let pixel = img.get_pixel; //Put a pixel at coordinate (100, 100) img.put_pixel; //Iterate over all pixels in the image for pixel in img.pixels
DynamicImage is an enumeration over all supported
Its exact image type is determined at runtime. It is the type returned when opening an image.
DynamicImage's reimplement all image processing functions.
DynamicImage implement the
GenericImage trait for RGBA pixels.
A view into another image, delimited by the coordinates of a rectangle. This is used to perform image processing functions on a subregion of an image.
extern crate image; use ; let ref mut img = new; let subimg = crop; assert!;
5 Image Processing Functions
These are the functions defined in the
imageops module. All functions operate on types that implement the
- blur: Performs a Gaussian blur on the supplied image.
- brighten: Brighten the supplied image
- contrast: Adjust the contrast of the supplied image
- crop: Return a mutable view into an image
- filter3x3: Perform a 3x3 box filter on the supplied image.
- flip_horizontal: Flip an image horizontally
- flip_vertical: Flip an image vertically
- grayscale: Convert the supplied image to grayscale
- invert: Invert each pixel within the supplied image This function operates in place.
- resize: Resize the supplied image to the specified dimensions
- rotate180: Rotate an image 180 degrees clockwise.
- rotate270: Rotate an image 270 degrees clockwise.
- rotate90: Rotate an image 90 degrees clockwise.
- unsharpen: Performs an unsharpen mask on the supplied image
6.1 Opening And Saving Images
image provides the
open function for opening images from a path.
The image format is determined from the path's file extension.
extern crate image; use File; use Path; use GenericImage;
6.2 Generating Fractals
//!An example of generating julia fractals. extern crate num; extern crate image; use File; use Path; use Complex;
6.3 Writing raw buffers
If the high level interface is not needed because the image was obtained by other means,
image provides the function
save_buffer to save a buffer to a file.
extern crate image;