3 releases (breaking)

0.3.0 Jan 9, 2024
0.2.0 Jan 6, 2021
0.1.0 Nov 5, 2020

#106 in Images

Download history 1093/week @ 2024-07-15 1151/week @ 2024-07-22 891/week @ 2024-07-29 1042/week @ 2024-08-05 965/week @ 2024-08-12 1224/week @ 2024-08-19 1214/week @ 2024-08-26 1242/week @ 2024-09-02 1101/week @ 2024-09-09 1172/week @ 2024-09-16 1659/week @ 2024-09-23 1301/week @ 2024-09-30 1467/week @ 2024-10-07 2155/week @ 2024-10-14 2005/week @ 2024-10-21 1796/week @ 2024-10-28

7,514 downloads per month
Used in 40 crates (2 directly)

MIT license

275KB
6K SLoC

qcms

Crates.io Documentation

Firefox's library for transforming image data between ICC profiles.

Example

    // Decode the jpeg
    let mut d = jpeg_decoder::Decoder::new(std::fs::File::open("/Users/jrmuizel/Desktop/DSCF2460.jpg").unwrap());
    let mut data = d.decode().unwrap();
    let info = d.info().unwrap();

    // Extract the profile after decode
    let profile = d.icc_profile().unwrap();

    // Create a new qcms Profile
    let input = qcms::Profile::new_from_slice(&profile).unwrap();
    let mut output = qcms::Profile::new_sRGB();
    output.precache_output_transform();

    // Create a transform between input and output profiles and apply it.
    let xfm = qcms::Transform::new(&input, &output, qcms::DataType::RGB8, qcms::Intent::default()).unwrap();
    xfm.apply(&mut data);

    // write the result to a PNG
    let mut encoder = png::Encoder::new(std::fs::File::create("out.png").unwrap(), info.width as u32, info.height as u32);
    encoder.set_color(png::ColorType::Rgb);
    encoder.set_srgb(png::SrgbRenderingIntent::Perceptual);
    let mut writer = encoder.write_header().unwrap();
    writer.write_image_data(&data).unwrap(); // Save

This library was originally written in C, was converted to Rust using c2rust, and then refactored to be mostly safe and more idiomatic Rust.

Dependencies