ImageSharp
ImageSharp copied to clipboard
Opening and saving jpeg using CMYK color space drastically changes image's color
Prerequisites
- [x] I have written a descriptive issue title
- [x] I have verified that I am running the latest version of ImageSharp
- [x] I have verified if the problem exist in both
DEBUG
andRELEASE
mode - [x] I have searched open and closed issues to ensure it has not already been reported
Description
The following image was created using the CMYK color space.
Loading this file and then saving results in this image.
(On my machine, the two images look the same in this issue but if you download the images, you will see the difference. Maybe github is experiencing the same thing 😃)
Steps to Reproduce
The following code is all you need to convert the first image into the second one. Note that this is a .Net Core 3.1 app using C#8.
const string FileName = "SolidColor_CYMK.jpeg";
using var image = Image.Load(FileName);
image.Save($"Modified - {FileName}");
System Configuration
- ImageSharp version: 1.0.0-rc.2
- Other ImageSharp packages and versions: N/A
- Environment (Operating system, version and so on): Win10 1809 x64
- .NET Framework version: .Net Core 3.1
- Additional information:
Yeah, that's expected. We don't have methods to correctly translate the CMYK color information. As you can see, many browsers do the same.
See previous related issues https://github.com/SixLabors/ImageSharp/issues/129 https://github.com/SixLabors/ImageSharp/issues/74
And related Work-In-Progress PR. https://github.com/SixLabors/ImageSharp/pull/273
Thanks for the quick response. I searched for CMYK and I had seen the other issue about ICC Profiles but I wasn't sure it was the same given that I thought I selected to not save the ICC profile when generating the image. I thought I limited it to just using CMYK and was semi-proud of myself since I am far from experienced with image processing 😄 .
Be proud. Image processing is hard! Hopefully we'll make it a little bit easier for all.
Maybe github is experiencing the same thing
No, it does not. It does not alter the bitstream of images. If it is, this is a bug in Chrome (there is none in CMYK, but only a bug in YCCK).
The fist file is CMYK file because exiftool says:
APP14 Flags 0 : (none) APP14 Flags 1 : (none) Color Transform : Unknown (RGB or CMYK)
This is ColorTransform = 0 which means it is RGB if 3 components and CMYK if 4. While second file outright says it is
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Image Size : 100x100 Megapixels : 0.010
So it is NOT CMYK AT ALL.
The first CMYK file does not have an ICC profile, since only RGB has a default of sRGB, it will be shown differently everywhere.
Is there a way to convert an RGB image to CMYK?
We currently don't support encoding jpeg as CMYK so any conversion we do would be lost.
Fixed via #2120