Page 1 of 1

Convert console command to c#

Posted: 2018-03-01T09:04:20-07:00
by Andrewxyz
Hello,
I try to convert this console command:

Code: Select all

convert EWwSX.jpg -fuzz 40% -fill white +opaque black result.png
To c#, now I'm have somthing like that,

Code: Select all

image.ColorFuzz = (Percentage)40; 
image.Settings.FillColor = MagickColors.White; 
image.Opaque(MagickColors.Black, MagickColors.Black); 
image.Write(@"C:\x.jpg");
But it still don't work as I expect. Can somebody help me with this? Propablly there is problem with:

Code: Select all

image.Opaque(MagickColors.Black, MagickColors.Black); 

Re: Convert console command to c#

Posted: 2018-03-05T13:56:00-07:00
by dlemstra
You don't need to set the fill color. One the command line this is the color used with +opaque but with Magick.NET it is one of the color arguments. You should do the following:

Code: Select all

image.InverseOpaque(MagickColors.Black,MagickColors.White);