magick.net alpha masking

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
dlinaresg
Posts: 6
Joined: 2013-02-20T16:37:00-07:00
Authentication code: 6789

magick.net alpha masking

Post by dlinaresg »

I want to apply an alpha mask onto a picture, just as in this post: viewtopic.php?t=30488. But I can't figure how can I translate the command from Imagemagick to magick.net:

Code: Select all

convert 3-sample.png -alpha on -background none ^
   ( +clone -channel a -evaluate multiply 0 +channel -fill white -draw "ellipse 153,128 57,57 0,360" ) ^
   -compose DstIn -composite circle_in.png
I can create the image, clone it and apply alpha:

Code: Select all

 using (MagickImage image = new MagickImage(filePath))
            {
                image.Alpha(AlphaOption.On);
                IMagickImage clone = image.Clone();                
            } 
But don't know how to code "-evaluate multiply 0".

Thank you
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: magick.net alpha masking

Post by dlemstra »

Most commands have are available as a method on the IMagickImage interface. Evaluate works like this:

Code: Select all

using (IMagickImage clone = image.Clone())
{
    // -channel a -evaluate multiply 0 +channel
    background.Evaluate(Channels.Alpha, EvaluateOperator.Multiply, 0);
}
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply