Debian Codegraph @

.cargo/vendor/moxcms/README.md

raw
1 # Rust ICC Management
2
3 Fast and safe conversion between ICC profiles; in pure Rust.
4
5 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.
6
7 ## Example
8
9 ```rust
10 let f_str = "./assets/dci_p3_profile.jpeg";
11 let file = File::open(f_str).expect("Failed to open file");
12
13 let img = image::ImageReader::open(f_str).unwrap().decode().unwrap();
14 let rgb = img.to_rgb8();
15
16 let mut decoder = JpegDecoder::new(BufReader::new(file)).unwrap();
17 let icc = decoder.icc_profile().unwrap().unwrap();
18 let color_profile = ColorProfile::new_from_slice(&icc).unwrap();
19 let dest_profile = ColorProfile::new_srgb();
20 let transform = color_profile
21 .create_transform_8bit(&dest_profile, Layout::Rgb8, TransformOptions::default())
22 .unwrap();
23 let mut dst = vec![0u8; rgb.len()];
24
25 for (src, dst) in rgb
26 .chunks_exact(img.width() as usize * 3)
27 .zip(dst.chunks_exact_mut(img.dimensions().0 as usize * 3))
28 {
29 transform
30 .transform(
31 &src[..img.dimensions().0 as usize * 3],
32 &mut dst[..img.dimensions().0 as usize * 3],
33 )
34 .unwrap();
35 }
36 image::save_buffer(
37 "v1.jpg",
38 &dst,
39 img.dimensions().0,
40 img.dimensions().1,
41 image::ExtendedColorType::Rgb8,
42 )
43 .unwrap();
44 ```
45
46 ## Benchmarks
47
48 ### ICC Transform 8-Bit
49
50 Tests were ran with a 1997×1331 resolution image.
51
52 | Conversion | time(NEON) | Time(AVX2) |
53 |--------------------|:----------:|:----------:|
54 | moxcms RGB⮕RGB | 2.68ms | 4.52ms |
55 | moxcms LUT RGB⮕RGB | 7.18ms | 17.50ms |
56 | moxcms RGBA⮕RGBA | 2.96ms | 4.83ms |
57 | moxcms CMYK⮕RGBA | 11.86ms | 27.98ms |
58 | lcms2 RGB⮕RGB | 13.1ms | 27.73ms |
59 | lcms2 LUT RGB⮕RGB | 27.60ms | 58.26ms |
60 | lcms2 RGBA⮕RGBA | 21.97ms | 35.70ms |
61 | lcms2 CMYK⮕RGBA | 39.71ms | 79.40ms |
62 | qcms RGB⮕RGB | 6.47ms | 4.59ms |
63 | qcms LUT RGB⮕RGB | 26.72ms | 60.80ms |
64 | qcms RGBA⮕RGBA | 6.83ms | 4.99ms |
65 | qcms CMYK⮕RGBA | 25.97ms | 61.54ms |
66
67 ## License
68
69 This project is licensed under either of
70
71 - BSD-3-Clause License (see [LICENSE](LICENSE.md))
72 - Apache License, Version 2.0 (see [LICENSE](LICENSE-APACHE.md))
73
74 at your option.