Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Automatic change of RGB images to greyscale - in jpgs

$
0
0
I just tested your image in Magick.NET and the following test fails:
using(MagickImage image = new MagickImage("grey_adobe_1998.jpg"))
{
  // This works
  Assert.AreEqual(ColorSpace.sRGB, image.ColorSpace);

  string tempFile = Path.GetTempFileName();
  image.Write(tempFile);
  image.Read(tempFile);
  File.Delete(tempFile);

  // This fails
  Assert.AreEqual(ColorSpace.sRGB, image.ColorSpace);
}
I also checked what happens in 'identify' on the command line and it turns out it will convert the image to grayscale when that is possible. So that is not really a good way to test it. I will talk with the rest of the IM team to see if we can change this. I think it should not attempt to change the image to grey.

The same is happening inside the JPEG writer. When it sees it can change the image to grey it will do that and write a grey image instead. You can avoid this by sett the colortype to true color:
string tempFile = Path.GetTempFileName();
image.ColorType = ColorType.TrueColor;
image.Write(tempFile);
image.Read(tempFile);
File.Delete(tempFile);

// This will now pass
Assert.AreEqual(ColorSpace.sRGB, image.ColorSpace);

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>