Improve ICC profile manipulation #3026
-
|
Hello, Note It's not a current need that I have, more like an idea, that I have in my head and I'm curious to know if this make sense or not and if it could be doable in the futur. I've been looking into the ICC Profiles and color conversion and I'm wondering, if something like that make sense and would be possible someday. var img1 = Image.Load(new DecoderOptions {ColorProfileHandling = ColorProfileHandling.Preserve, "image-using-rgb-profile");
var img2 = Image.Load(new DecoderOptions {ColorProfileHandling = ColorProfileHandling.Preserve, "image-using-some-cmyk-profile");
// So here the idea is to create an image, working with CIELab or CIEXYZ with like `Vector4` for each pixel
using var canvas = Image.CreateCieLabImage(100, 100);
// When writting the images, it convert it, but only stop to the the CIELab / CIEXYZ color space
// This aim to have no loss in scenario where all the colors of the image are contained in the gamut
// of the source and destination profile, but not in sRGB
canvas.Mutate(x => x.DrawImage(img1))
canvas.Mutate(x => x.DrawImage(img2))
// Then we save it to the file with the destination profile (for example CMYK)
var destinationProfile = new IccProfile(File.ReadAllBytes("destination.icc"))
canvas.SaveAndApplyProfile(destinationProfile, "some-file.png")So at the end the color from each image would have not been converted to the sRGB colors space. Maybe this make no sense and I misunderstood something, let me know if this is the case. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I'm afraid that will never be possible.
|
Beta Was this translation helpful? Give feedback.
In ImageSharp,
Image<TPixel>is the in-memory surface type.TPixelis any unmanaged struct that implementsIPixel<TPixel>, which in turn extends the non genericIPixel. The key part of that base interface is the conversion contract:TPixelmust be able to:Rgba32(ToRgba32,FromRgba32)Vector4view (ToScaledVector4,FromScaledVector4,ToVector4,FromVector4)See
IPixelandIPixel<TSelf>.ToScaledVector4andFromScaledVector4use normalized 0-1 values in least to most significant channel order (R, G, B, A forRgba32). This is documented onIPixel<TSelf>.All processors operate on that RGBA
Vector4view. Blend modes, filters, drawing, qua…