Crates.io | palette-transfer |
lib.rs | palette-transfer |
version | 0.2.0 |
source | src |
created_at | 2024-08-03 16:06:49.628033 |
updated_at | 2024-10-13 19:35:00.886556 |
description | Statistical copy palette from one image to another |
homepage | https://github.com/awxkee/palette-transfer.git |
repository | https://github.com/awxkee/palette-transfer.git |
max_upload_size | |
id | 1324419 |
size | 990,194 |
Copies palette from source image to destination using different color spaces and statistics approach.
let source = ImageReader::open("./assets/dwl.jpeg")
.unwrap()
.decode()
.unwrap();
let source_dimensions = source.dimensions();
let destination = ImageReader::open("./assets/twl.jpeg")
.unwrap()
.decode()
.unwrap();
let destination = destination.to_rgb8();
let destination_dimension = destination.dimensions();
let src = source.as_bytes();
let target = destination.as_bytes();
let mut dst = Vec::from(target);
copy_palette_rgb(
src,
source_dimensions.0,
source_dimensions.1,
& mut dst,
destination_dimension.0,
destination_dimension.1,
1.,
TransferColorspace::OKLAB,
)
.unwrap();
image::save_buffer(
"converted_oklab.jpg",
& dst,
destination_dimension.0,
destination_dimension.1,
image::ExtendedColorType::Rgb8,
)
.unwrap();