I just tested your image in Magick.NET and the following test fails:
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:
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); }
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);