covnersion from CMYK to RGB from version 7.14

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Locked
lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

covnersion from CMYK to RGB from version 7.14

Post by lucd »

Hello,

I was still using the version 7.12.0
after upgrading to latest version, the cmyk converted to rgb have their colors off
I made tests with the very same code (just upgrading the nuget package) and here are the results with the same image


Image

Image

Image

Code: Select all

 image.TransformColorSpace(ColorProfile.USWebCoatedSWOP, ColorProfile.SRGB);
In 7.12.0 the converted image lacks some dark/contract compared to Photoshop (no proof colors applied, using "working cmyk"

Image


For now i reverted to latest working version (7.13.1)
Do i miss something?
I didn't find info in the releases notes or this forum

thanks !

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

This almost looks like you were working around a bug in those older version. But you are not providing enough information to help you. Can you add a complete sample that demonstrates this issue and also include the sample image where you are having this problem. My email can be found on my GitHub profile if you cannot share it in public.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: covnersion from CMYK to RGB from version 7.14

Post by lucd »

Well, not sure the code is doing much, as i use exactly the same code / source image,
just changing the nuget version causes the issue
i'll make a video to show you

here is a quick extract of the relevant code, i'll prepare a standalone class to reproduce it

Code: Select all


// content is a Stream (file read from storage)

MagickReadSettings settings = new MagickReadSettings
{
	FrameIndex = 0,
	FrameCount = 1,
	Density = new Density(300, 300, DensityUnit.PixelsPerInch)
};

MagickImageCollection magickImageCollection = new MagickImageCollection(content, settings);
IMagickImage image = magickImageCollection.Flatten(new MagickColor(MagickColors.Transparent));
		
 // remove tiff layers contained in profiles
 image.RemoveProfile("tiff:37724");
 
  
  //transform CMYK to sRGB
	if (image.ColorSpace == ColorSpace.CMYK)
	{
		// remove all profiles
		image.RemoveProfile("icc");
		image.RemoveProfile("USWebCoatedSWOP");
		image.RemoveProfile(imageFormat.DefaultIccProfile);

		// convert using a default cmyk profile
		image.TransformColorSpace(ColorProfile.USWebCoatedSWOP, ColorProfile.SRGB);
	}

	image.Format = MagickFormat.Png32;                                  
	image.BackgroundColor = new MagickColor(MagickColors.Transparent);

	image.Strip(); // remove extra stuff (included color profiles)

	return  image.ToByteArray()


User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

Please share your image here (with a link) or email me a link where I can download it.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: covnersion from CMYK to RGB from version 7.14

Post by lucd »


User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

The problem seems to be that you first assign the USWebCoatedSWOP profile and then transform from that colorprofile. I suspect that for some reason this did nothing in the older version of Magick.NET and now started working and giving you an incorrect result. My advise would be to just do this:

Code: Select all

if (image.ColorSpace == ColorSpace.CMYK)
{
    image.TransformColorSpace(ColorProfile.SRGB);
}
This will transform from the color profile of the image to sRGB. If the image has no profile it will not do anything. And when the png file is created the colorspace will be changed to sRGB and give you the expected result.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: covnersion from CMYK to RGB from version 7.14

Post by lucd »

Unfortunately that doesn't work, the colors are totally off (indeed like if the colorspace was ignored cmyl > rgb classic flashy colors in this case)


center are correct colors (originals in photoshop),
external converted using image.TransformColorSpace(ColorProfile.SRGB) in v7.14

Image

internal are correct, converted using image.TransformColorSpace(ColorProfile.USWebCoatedSWOP, ColorProfile.SRGB) in 7.13
external colors are off, converted using image.TransformColorSpace(ColorProfile.SRGB) in v7.14

Image

lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: covnersion from CMYK to RGB from version 7.14

Post by lucd »

Previously i could add a profile using "AddProfile"
but this command had gone ??
I can't find release notes

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

The release notes can be found here: https://github.com/dlemstra/Magick.NET/ ... g/7.16.0.0

p.s. Thanks for the whisky.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: covnersion from CMYK to RGB from version 7.14

Post by lucd »

Hello,

thanks for the notes, i found the missing information there...
With the new boolean ColorTransformMode.HighRes, colors are correct

The image must be converted from a the cmyk profile, else colors are totally off, as expected

Code: Select all

 image.TransformColorSpace(ColorProfile.USWebCoatedSWOP, ColorProfile.SRGB, ColorTransformMode.HighRes);
 
I don't understand how come this was not mentionned by someone else before ?
Am i the only one to work with CMYK files lol ?


Anyhow, solved !! Thanks


And ... Cheers,

Luc

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

Could you share your other images also? I wonder why there is such a big difference between the HighRes and Quantum transformation.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

I was able to reproduce the issue with your initial test image and after doing some more investigating I found a bug. I will publish a new release today to fix that and in the next release you will no longer need to specify ColorTransformMode.HighRes. Using the default (Quantum) will be faster but you will get better precision with HighRes.

Thanks for reporting this.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: covnersion from CMYK to RGB from version 7.14

Post by dlemstra »

7.17.0.1 has been released.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

lucd
Posts: 22
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: covnersion from CMYK to RGB from version 7.14

Post by lucd »

Thanks !!

Locked