Crates.io | color-reduction |
lib.rs | color-reduction |
version | 0.1.2 |
source | src |
created_at | 2021-07-12 05:30:30.331224 |
updated_at | 2022-03-14 21:39:13.222049 |
description | A library to reduce the colors of an image to a specified set of colors. |
homepage | https://github.com/Monology/color-reduction |
repository | https://github.com/Monology/color-reduction |
max_upload_size | |
id | 421775 |
size | 6,667 |
A Rust library to reduce the colors of an image to a specified set of colors.
... combined with ...
use color_reduction::reduce_colors;
use color_reduction::image::Rgb;
use color_reduction::image;
fn main() {
let image = image::open("./old-image.jpg")
.expect("error loading image");
let new_image = reduce_colors(image, &[
Rgb::from([240,207,149]),
Rgb::from([24,30,75]),
Rgb::from([10,6,11]),
Rgb::from([142,117,98]),
Rgb::from([67,62,70]),
Rgb::from([28,42,84]),
Rgb::from([19,13,20]),
Rgb::from([248,217,158]),
Rgb::from([9,4,7]),
Rgb::from([62,53,52]),
Rgb::from([62,71,99]),
Rgb::from([134,125,118]),
Rgb::from([198,154,106]),
Rgb::from([15,14,59]),
Rgb::from([113,90,78]),
Rgb::from([255, 255, 255]),
Rgb::from([255, 249, 189]),
]);
new_image.save("./new.jpg").expect("error saving image");
}
... turns into ...