Moxcms
Fast and safe color management system in Rust
Install / Use
/learn @awxkee/MoxcmsREADME
Rust ICC Management
Fast and safe conversion between ICC profiles; in pure Rust.
Supports CMYK⬌RGBX, RGBX⬌RGBX, RGBX⬌GRAY, LAB⬌RGBX and CMYK⬌LAB, GRAY⬌RGB, any 3/4 color profiles to RGB and vice versa. Also supports almost any to any Display Class ICC profiles up to 16 inks.
Example
let f_str = "./assets/dci_p3_profile.jpeg";
let file = File::open(f_str).expect("Failed to open file");
let img = image::ImageReader::open(f_str).unwrap().decode().unwrap();
let rgb = img.to_rgb8();
let mut decoder = JpegDecoder::new(BufReader::new(file)).unwrap();
let icc = decoder.icc_profile().unwrap().unwrap();
let color_profile = ColorProfile::new_from_slice(&icc).unwrap();
let dest_profile = ColorProfile::new_srgb();
let transform = color_profile
.create_transform_8bit(&dest_profile, Layout::Rgb8, TransformOptions::default())
.unwrap();
let mut dst = vec![0u8; rgb.len()];
for (src, dst) in rgb
.chunks_exact(img.width() as usize * 3)
.zip(dst.chunks_exact_mut(img.dimensions().0 as usize * 3))
{
transform
.transform(
&src[..img.dimensions().0 as usize * 3],
&mut dst[..img.dimensions().0 as usize * 3],
)
.unwrap();
}
image::save_buffer(
"v1.jpg",
&dst,
img.dimensions().0,
img.dimensions().1,
image::ExtendedColorType::Rgb8,
)
.unwrap();
Benchmarks
ICC Transform 8-Bit
Tests were ran with a 1997×1331 resolution image.
| Conversion | time(NEON) | Time(AVX2) | |--------------------|:----------:|:----------:| | moxcms RGB⮕RGB | 2.68ms | 4.52ms | | moxcms LUT RGB⮕RGB | 7.18ms | 17.50ms | | moxcms RGBA⮕RGBA | 2.96ms | 4.83ms | | moxcms CMYK⮕RGBA | 11.86ms | 27.98ms | | lcms2 RGB⮕RGB | 13.1ms | 27.73ms | | lcms2 LUT RGB⮕RGB | 27.60ms | 58.26ms | | lcms2 RGBA⮕RGBA | 21.97ms | 35.70ms | | lcms2 CMYK⮕RGBA | 39.71ms | 79.40ms | | qcms RGB⮕RGB | 6.47ms | 4.59ms | | qcms LUT RGB⮕RGB | 26.72ms | 60.80ms | | qcms RGBA⮕RGBA | 6.83ms | 4.99ms | | qcms CMYK⮕RGBA | 25.97ms | 61.54ms |
License
This project is licensed under either of
at your option.
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
