How to convert these IM commands to Magick.NET?
Posted: 2016-08-09T11:58:19-07:00
I have two Shell-script convert.exe commands I'm trying to convert over to use the .NET library. Can anyone provide guidance here?
First, I'm trying to remove the backdrop (trim doesn't work as well as this script does).
Part of shell-script:
Blur and threshold in Magick.NET are easy, but not sure about the rest.
-----
On a different process, I've been trying to get the blue channel from the image to filter on, but I am unable to figure it out in Magick.NET. image2.Separate(Channels.Blue) isn't giving me what I expected.
Part of shell-script:
What I have so far in .NET:
Any help would be greatly appreciated!
First, I'm trying to remove the backdrop (trim doesn't work as well as this script does).
Part of shell-script:
Code: Select all
var=`convert ./input.jpg -blur 0x4 -threshold 45% -format %@ info:`
convert ./input.jpg -crop $var ./output.jpg
Code: Select all
Magick image = new Magick();
image = new MagickImage(input);
image.Blur(0, 4);
image.Threshold(new ImageMagick.Percentage(45));
image.Write(output);
On a different process, I've been trying to get the blue channel from the image to filter on, but I am unable to figure it out in Magick.NET. image2.Separate(Channels.Blue) isn't giving me what I expected.
Part of shell-script:
Code: Select all
convert ./input.jpg ( +clone -colorspace RGB -channel B -separate +channel -auto-level -threshold 16% +write x.png ) -compose Lighten -composite ./output.jpg
Code: Select all
Magick image = new Magick();
image = new MagickImage(input);
image2 = image.Clone();
image2.ColorSpace = ColorSpace.RGB;
//image2.Separate(Channels.Blue);
image.AutoLevel();
image.Threshold(new ImageMagick.Percentage(16));
//image2.Write("D:\\temp\\image2.png");
image.Composite(image2, CompositeOperator.Lighten);
image.Write(output);