0

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!

Robert Schaaf
  • 81
  • 1
  • 3

1 Answers1

1

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);
emcconville
  • 23,800
  • 4
  • 50
  • 66
  • Thanks, but I didn't see this. For some reason, the call isn't implemented in the go bindings. – Robert Schaaf Apr 19 '21 at 05:02
  • It isn't currently in the Go bindings because I do not see it being declared in the ImageMagick headers: https://imagemagick.org/api/MagickWand/magick-image_8h.html Any idea why it seems to only be defined in the source? https://imagemagick.org/api/MagickWand/magick-image_8c.html#ae73b82133a34dabd4b322cc8823573c3 – jdi Apr 19 '21 at 20:10
  • @jdi Looks like you discovered a bug (or oversight?). [Method was defined](https://github.com/ImageMagick/ImageMagick/blob/fea4e7aa391c625765febcb508dc17f971934386/MagickWand/magick-image.c#L9980), but not exposed to the headers. – emcconville Apr 19 '21 at 21:26