SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.35k stars 849 forks source link

Opening and saving jpeg using CMYK color space drastically changes image's color #1238

Closed gsfreema closed 2 years ago

gsfreema commented 4 years ago

Prerequisites

Description

The following image was created using the CMYK color space.

SolidColor_CYMK

Loading this file and then saving results in this image.

Modified - SolidColor_CYMK

(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

JimBobSquarePants commented 4 years ago

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

gsfreema commented 4 years ago

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 😄 .

JimBobSquarePants commented 4 years ago

Be proud. Image processing is hard! Hopefully we'll make it a little bit easier for all.

timdinhdotcom commented 2 years ago

Is there a way to convert an RGB image to CMYK?

JimBobSquarePants commented 2 years ago

We currently don't support encoding jpeg as CMYK so any conversion we do would be lost.

JimBobSquarePants commented 2 years ago

Fixed via #2120