How to set auto-grayscale off?

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

How to set auto-grayscale off?

Post by 246246 »

According to this, viewtopic.php?f=3&t=34337, I have not yet find a way to accomplish to avoid RGB image (where all values are r=g=b) to be converted to grayscale. How to do it in Magick.NET?

Best Wishes,


PS
I do not want to use -type TrueColor, because the input might be indexed color whose all values are gray (r=g=b).
In that case, it should keep the Palette type.
Last edited by 246246 on 2018-07-11T05:55:54-07:00, edited 3 times in total.
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: How to set auto-grayscale off?

Post by 246246 »

In the most recent Magick.NET 7.5.0.1, it seems

Code: Select all

using (var image = new MagickImage("c:/tmp/logo.tif"))
{
    image.SetAttribute("colorspace:auto-grayscale", "false");
    image.Write("c:/tmp/out.tif");
}
is working.

My first code was

Code: Select all

using (var image = new MagickImage("c:/tmp/logo.tif"))
{
    image.Settings.SetDefine("colorspace:auto-grayscale", "false");
    image.Write("c:/tmp/out.tif");
}
It does not work. Is my working code in the right way?
Post Reply