#Little CMS wrapper for Rust
Convert and apply color profiles with a safe abstraction layer for the LCMS library.
extern crate rgb;
extern crate lcms2;
use lcms2::*;
fn main() {
let icc_file = include_bytes!("custom_profile.icc");
let custom_profile = Profile::new_icc(icc_file).unwrap();
let srgb_profile = Profile::new_srgb();
let t = Transform::new(&custom_profile, PixelFormat::RGB_8, &srgb_profile, PixelFormat::RGB_8, Intent::Perceptual);
let source_pixels: &[rgb::RGB<u8>] = …;
t.transform_pixels(source_pixels, destination_pixels);
t.transform_in_place(source_and_dest_pixels);
}
See examples
dir and LCMS2 documentation PDF for more info.
To apply ICC profile in JPEG:
if "ICC_PROFILE\0".as_bytes() == &app2_marker_data[0..12] {
let icc = &app2_marker_data[14..]; let profile = Profile::new_icc(icc).unwrap();
let t = Transform::new(&profile, PixelFormat::RGB_8,
&Profile::new_srgb(), PixelFormat::RGB_8, Intent::Perceptual);
t.transform_in_place(&mut rgb);
}