We can mask a png image over any other image with rotation and proper alignment.
Let say for example, if we need to replace the human face of an image with another face, then we need this type of masking. There are various ways and command within imagemagick but I found this command combination very suitable:
Main image: myimage.jpeg
New face: mask.png
rotation angle:15 degree
X position: 200px
Y position: 100px
face width: 40px
face height: 50px
convert myimage.jpeg \( mask.png -resize 40x50 -background none -virtual-pixel background +distort SRT 15 \) -geometry +200+100 -composite newimage.jpeg
This command will also remove black background around replaced png. Hope this will help someone.