This project has moved and is read-only. For the latest updates, please go here.

Applied ColorProfiles not having an effect on MagickImages

Aug 4, 2013 at 12:56 PM
I'm struggling to use MagickNet to colour-correct images. My wide-gamut monitor requires that images be colour-adjusted if they are not to display extremely exaggerated red hues.

So, I have been experimenting with using MagickImage.AddProfile() to apply a new ColorProfile to images, that I create by loading my monitor's colour profile from disk. At first this seemed to be working, but then I realised that it was only having an effect for images that already have the sRGB profile applied (or, it would seem, any other profile). Non-colour managed images are not affected by adding the monitor profile.

I just can't understand why it would be necessary for an image to have a colour profile already applied to be affected by applying a new, different one.

Additionally, RemoveProfile() appears to have no effect. In the following code, the call to RemoveProfile does nothing.
image.AddProfile(new ColorProfile(@"C:\...\LP2475w_20090407.icc"));
image.RemoveProfile(image.GetColorProfile().Name);
Aug 4, 2013 at 4:23 PM
I am not an expert with color profiles but maybe you can get the same result if you first add the sRGB color profile (ColorProfile.SRGB) and then add your own. I have also tested the code you posted and in my unit test it removes the profile. The next call to image.GetColorProfile() will return null.
Aug 4, 2013 at 9:33 PM
Edited Aug 4, 2013 at 9:35 PM
I had actually already tried manually setting an sRGB profile just as you suggested, but it made no difference. It seems to need to be embedded in the image file to begin with. To be clear, this is what I am currently running:
image = new MagickImage();
image.Read(@"E:\test.jpg");
image.AddProfile(ColorProfile.SRGB);      
image.AddProfile(new ColorProfile(@"C:\...\LP2475w_20090407.icc"));
which does not apply the colour profile
image = new MagickImage();
image.Read(@"E:\test sRGB.jpg");     
image.AddProfile(new ColorProfile(@"C:\...\LP2475w_20090407.icc"));
... whereas this does (test sRGB.jpg is exactly the same image file, but set in Photoshop to use the default system sRGB profile instead of not being colour managed; the image data is identical).

As for RemoveProfile(), I have played around a bit more. It seems to work only on profiles that were added programmatically. In other words, it will remove a colour profile that was previously added with AddProfile(), but it will not remove a profile that is associated with the image in the file on disk that the image was read from.