I have successfully created a image with the form of a square diamond by providing an original image and a masking image with background black alpha 0 and the diamond square white with alpha 1.
I use the following gm command
gm composite -compose in orgiginal.jpg diamond-mask.png result.png
Now I would like to reproduce the result using node.js gm module.
I think node-gm doesn't provide support for composite/compose.
However there is a fork of GM on github that may be worth exploring: https://github.com/fanzter/gm/commit/822c917bbaaf984920e6625b65acd6d21c3ac360