Equivalent of clip-mask

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
Posts: 1
Joined: 2019-05-01T13:22:54+00:00
Authentication code: 1152

Equivalent of clip-mask

Post by bredstrup »


sorry, I am very new to ImageMagick. I have this command line arguments, that I need to convert to .NET / c#:

-define psd:alpha-unblend=off -trim "inout image" -clip-mask -resize 1600> "outputimage"

I've got this so far:

var setting = new MagickReadSettings { Defines = new PsdReadDefines { AlphaUnblend = false } };
using (var image = new MagickImage(file, setting))
image.Resize(new MagickGeometry { Greater = true, Width = _maxSize, Height = _maxSize });
return image.ToByteArray(MagickFormat.Png);

I do not know how to get -clip-mask into c#. Using the above code works, but produces a PNG with a "black" background in some image viewers. Using Image Magick with the native commandline args above does not yield this black background.

I am very thankful for any help.

Anders Pedersen
User avatar
Posts: 1570
Joined: 2013-05-04T22:28:54+00:00
Authentication code: 6789

Re: Equivalent of clip-mask

Post by dlemstra »

image.Clip is the equivalent of -clip-mask in Magick.NET
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply