Thank you!
It would be excellent if either it stopped automatically converting images to greyscale, or at least there was an option you could use to disable automatic colour conversion.
Sometime last week, when I was looking into this, I found this article:
http://www.imagemagick.org/script/color-management.php
It looks like automatic greyscaling was added to IM deliberately.
So what I was doing was just coming up with workarounds.
I haven't tried it for all image file types, but for .tif and .jpg it always tries to automatically greyscale any RGB images which are grey.
The difference is that for .tif files, I could detect the original colour info and store it in some variables, handle profiles / resize images, then set the colour info back on the image before writing the file out. So that was my workaround.
For .jpg files, it was converting the image before I could get a chance to detect the original colour info.
As I have one piece of code to handle images of multiple different types, the problem was that I didn't know how to detect that an image was originally an RGB jpg which is grey. My workaround for .jpg is now:
The better solution would be for IM to not automatically convert grey RGB images to greyscale, though.
It would be excellent if either it stopped automatically converting images to greyscale, or at least there was an option you could use to disable automatic colour conversion.
Sometime last week, when I was looking into this, I found this article:
http://www.imagemagick.org/script/color-management.php
It looks like automatic greyscaling was added to IM deliberately.
So what I was doing was just coming up with workarounds.
I haven't tried it for all image file types, but for .tif and .jpg it always tries to automatically greyscale any RGB images which are grey.
The difference is that for .tif files, I could detect the original colour info and store it in some variables, handle profiles / resize images, then set the colour info back on the image before writing the file out. So that was my workaround.
For .jpg files, it was converting the image before I could get a chance to detect the original colour info.
As I have one piece of code to handle images of multiple different types, the problem was that I didn't know how to detect that an image was originally an RGB jpg which is grey. My workaround for .jpg is now:
if (image.ClassType == ClassType.Direct && image.ColorType == ColorType.Grayscale)
{
image.ColorType = ColorType.TrueColor;
}
i.e. if the class type was previously Direct, that implies that it should be an RGB image. If it is now greyscale, that doesn't match - so then it sets the ColorType to TrueColor.The better solution would be for IM to not automatically convert grey RGB images to greyscale, though.