dlemstra / Magick.NET

The .NET library for ImageMagick
Apache License 2.0
3.46k stars 416 forks source link

ImageMagick doesn't use Embedded color profile of image #36

Closed d2phap closed 7 years ago

d2phap commented 7 years ago

Thanks for the very useful lib.

How to apply automatically embedded color profile of an image? I have an image, when I use:

using (var img = new MagickImage(path))
{
      bmp = img.ToBitmap();
}

the color of image displayed incorrectly: image

Before that, using .NET Bitmap, I can write: bmp = new Bitmap(path, true);

This is my sample file: color_mgn

Thank you

dlemstra commented 7 years ago

I am not sure if what you are seeing in your example file are the correct colors. I get the same "incorrect color" with just the following command:

using (Bitmap image = new Bitmap("ffbdd072-e0b8-11e6-9693-e5dd40721972.jpg", true))
{
  image.Save("test.png", ImageFormat.Png);
}

It does depend where I view it though. In the PhotoViewer of Win10 I get the "correct color" but Chrome shows the "incorrect color". I can however get the result that you want in both apps with the following code:

using (MagickImage image = new MagickImage("ffbdd072-e0b8-11e6-9693-e5dd40721972.jpg"))
{
  image.AddProfile(ColorProfile.SRGB);
  using (var bitmap = image.ToBitmap())
  {
    bitmap.Save("test.png");
  }
}
d2phap commented 7 years ago

Thanks, this helped!