CMX: Rust Spectral Color Management Library
This crate provides utilities for working with ICC color profiles and integrates with the Colorimetry Library.
Use Cases
Each ICC profile tag is mapped to a key in the TOML file, with the corresponding values serialized as key-value pairs. All values are written as single-line entries to ensure the TOML output remains human-readable and easy to inspect.
Example of a parsed ICC profile in TOML format:
= 548
= "Apple"
= "4.0"
= "Display"
= "RGB"
= "XYZ"
= "2015-10-14 13:08:56 UTC"
= "Apple"
= "APPL"
= "Perceptual"
= [0.9642, 1.0, 0.8249]
= "appl"
= "53410ea9facdd9fb57cc74868defc33f"
[]
= "SMPTE RP 431-2-2007 DCI (P3)"
[]
= "Copyright Apple Inc., 2015"
[]
= [0.894592, 1.0, 0.954422]
[]
= [0.48616, 0.226685, -0.000809]
[]
= [0.323853, 0.710327, 0.043228]
[]
= [0.15419, 0.062988, 0.782471]
[]
= 2.60001
[]
= [
[1.073822, 0.038803, -0.036896],
[0.055573, 0.963989, -0.014343],
[-0.004272, 0.005295, 0.862778]
]
[]
= 2.60001
[]
= 2.60001
You can also use the cmx library to create ICC profiles from scratch, or read existing
profiles and change them, using Rust.
The library provides a builder-style API for constructing, or read and change profiles, allowing you to set or change various tags and properties.
Here is an example for creating a Display P3 ICC profile:
use ;
use *;
use DisplayProfile;
let display_p3_example = new
// set creation date, if omitted, the current date and time are used
.with_creation_date
.with_tag
.as_text_description
.with_tag
.as_text
.with_tag
.as_xyz_array
.with_tag
.as_xyz_array
.with_tag
.as_xyz_array
.with_tag
.as_xyz_array
.with_tag
.as_parametric_curve
.with_tag
.as_parametric_curve
.with_tag
.as_parametric_curve
.with_tag
.as_sf15_fixed_16_array
.with_profile_id // calculate and add profile ID to the profile
;
display_p3_example.write.unwrap;
let display_p3_read_back = read.unwrap;
assert_eq!;
assert_eq!;
Not all ICC tag types are supported yet, but please submit a pull request, or an issue, on our GitHub CMX repo if you want additional tag types to be supported.
However, you can use the as_raw method to set raw data for tags that are not yet supported.
Installation
Install the cmx tool using Cargo:
To use the cmx library in your Rust project:
Documentation is available at docs.rs/cmx.
Roadmap
- Parse full ICC profiles
- Convert to TOML format
- Add builder-style API for constructing ICC profiles
- Support basic ICC Type tags and color models
- Read TOML Color profiles and convert to binary ICC profiles
- Utilities for commandline profile conversion and manipulation
- Calibration and profiling tools
- X-Rite I1 Profiler support
- Support all ICC Type tags
- Enable spectral data and advanced color management
Overview
Although the ICC specification is broad and complex, this crate aims to provide a robust foundation for working with ICC profiles in Rust.
It supports parsing, constructing, and changing of the primary ICC-defined tags, as well as some commonly used non-standard tags.
Even tags that cannot yet be parsed are still preserved when reading and serializing profiles, ensuring no data loss.
The long-term goal is to fully support advanced ICC color management, including spectral data and extended color models, while maintaining compatibility with existing profiles.
License
Licensed under either of
-
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
-
MIT license (LICENSE-MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.