Page 1 of 1

Converting Magick command line to C# .net

Posted: 2018-03-14T00:22:42-07:00
by stealthrt
Hey all I am in need of some help with converting this command line to C#:

Code: Select all

convert YnTf9.png \
\( -clone 0 -blur 0x10 -gravity center -crop 400x300+0+0 +repage \) \
\( -clone 0 -resize x300 \) \
\( -clone 1 -fill white -colorize 100 \) \
\( -clone 2 -fill black -colorize 100 \) \
\( -clone 3,4 -gravity center -compose over -composite -blur 0x15 -level 40x100% \) \
-delete 0,3,4 \
\( -clone 0,2 -gravity center -compose multiply -composite \) \
-delete 0,2 +swap \
-gravity center -compose over -composite \
result.png
The only thing I could come up with is:

Code: Select all

using (MagickImage image = new MagickImage("i:/YnTf9.png"))
{
    using (IMagickImage backgroundImg = image.Clone())
    {
        backgroundImg.Blur(0, 5);
        backgroundImg.Crop(400, 300, Gravity.Center);
        backgroundImg.RePage();

        image.Resize(0, 300);

        //Shadow
        MagickImage shadowImgWhite = image.Clone();
        shadowImgWhite.Colorize(MagickColors.White, new Percentage(50));
        IMagickImage shadowImgBlack = image.Clone();
        shadowImgBlack.Colorize(MagickColors.Black, new Percentage(50));

        backgroundImg.Composite(image, Gravity.Center, CompositeOperator.SrcOver);
        //TODO: Delete 0,3,4 Clones?
        //TODO: Clone 0,2 -gravity, center, compose over, composit, blur, level 40x100%?
        //TODO: Delete 0,2 Clones +swat
        //TODO: gravity, center, compose over, composite
        backgroundImg.Write("i:/result.png");
    }
 }

Re: Converting Magick command line to C# .net

Posted: 2018-03-14T17:52:06-07:00
by stealthrt
Still needing help with the conversions.

Re: Converting Magick command line to C# .net

Posted: 2018-03-15T09:25:07-07:00
by stealthrt
Got it

Code: Select all

using (MagickImage image = new MagickImage(bitmap))
    {
        using (IMagickImage backgroundImg = image.Clone())
        {
            backgroundImg.Blur(0, 5);
            backgroundImg.Crop(400, 300, Gravity.Center);
            backgroundImg.RePage();

            image.Resize(0, 300);

            IMagickImage _shadow = new MagickImage(MagickColor.FromRgb(0, 0, 0), image.Width + 20, 400);
_shadow.Shadow(backgroundImg.Width, 400, 10, (Percentage)90);

            backgroundImg.Composite(_shadow, Gravity.Center, CompositeOperator.Atop);
            backgroundImg.Composite(image, Gravity.Center, CompositeOperator.SrcAtop);
            backgroundImg.Write(@"C:\Users\David\Pictures\NEWest.png");
        }
    }