MagickWand 7 API: how to port MagickSetImageClipMask call

57 views Asked by At

ImageMagick 7 dropped this call, but I can't find any example of how to replicate its functionality in the new version. My aim is to composite two images with a mask. Here's vastly simplified go code for what I was doing in version 6.

func CleanUpImage(originalImage, maskImage *imagick.MagickWand) (*imagick.MagickWand, error) {

    err error;
    
    targetImage = imagick.NewMagickWand();  
    pw = imagick.NewPixelWand();

    width = originalImage.GetImageWidth(); 
    height = originalImage.GetImageHeight();
    _ = pw.SetColor("white");
    
    _ = targetImage.NewImage(width, height, pw);

    _ = targetImage.SetImageClipMask(maskImage);

    _ = targetImage.CompositeImage(originalImage, imagick.COMPOSITE_OP_COPY, 0, 0);
    
    return targetImage, err;
}

Can anyone give me guidance about getting this running in version 7?

Thanks!

1

There are 1 answers

3
emcconville On

I'm unfamiliar with the GO bindings, but MagickSetImageClipMask() was replaced with MagickSetImageMask() in ImageMagick-7. The only difference is that users can define the direction (Read/Write) of the mask.

To match ImageMagick-6's ClipMask, you would set the image mask to write.

MagickSetImageMask(image_wand, WritePixelMask, mask_wand);