Convert console command to c#

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
Andrewxyz
Posts: 1
Joined: 2018-03-01T09:00:36-07:00
Authentication code: 1152

Convert console command to c#

Post 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); 
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert console command to c#

Post 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);
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply