Note: this is not high priority for me, just a convenience and potential usefulness to others due to the complexity of the current solutions above.
Code: Select all
convert img.png mask.png -define compose:mask-channel=red -compose multiplyopacity -composite result.png
The compose method would be multiplyopacity (with optional hyphen or underscore as in copy_opacity, so multiply_opacity or multiply-opacity are allowed)
The default if no -define would be the red (first) channel of the mask, so that if it were a grayscale image, in IM 7 that would be the only channel. The define is optional, but it would be nice to be able to select a channel if the mask image is not grayscale.