10 stable releases
new 2.4.3 | Mar 4, 2025 |
---|---|
2.4.0 | Mar 3, 2025 |
2.2.0 | Feb 23, 2025 |
1.0.0 | Jan 1, 2024 |
0.1.0 | Jun 2, 2023 |
#132 in Images
1,054 downloads per month
110KB
2.5K
SLoC
Photo
Utility image classes for Rust.
Features
- Grayscale, Grascale with alpha, RGB and RGBA images, as well as custom color types.
- Colour maps
- Image IO
- Image transformations utilities.
- Tile manipulation.
- Generic precision types for image components:
u8
,f32
,f64
etc. - Print images to the console.
Usage
Reading and writing images
Loading a RGB image with f32 components:
use photo::ImageRGB;
let mut image = ImageRGB::<f32>::load("input/my_colour_image.png").expect("Failed to load image");
Save it:
image.save("output/my_colour_image.png").expect("Failed to save image");
Image transformations
image.flip_horizontal();
image.rotate_clockwise();
Tiling
let tile_size = (14, 14); // 14x14 pixel tiles
let tiles: Arrray2<ImageRGB> = image.tiles(tile_size);
Colour maps
let colours = vec!["#FF0000", "#00FF00", "#0000FF00"];
let colour_map: ColourMap<f32, LinSrgba> = ColourMap::new(&colours);
let sample = colour_map.sample(0.75);
Colourize grayscale images
use photo::ImageG;
let grayscale_image = ImageG::<u8>::load("input/my_grayscale_image.png").expect("Failed to load image");
let coloured_image = grayscale_image.colourize(&colour_map);
Print images to the console
println!("{}", image);
Dependencies
~6MB
~115K SLoC