imagemagicktransparencyalpha-transparency

Draw a rounded rectangle over an existing image in ImageMagick v6


It is straightforward to draw a filled rounded rectangle in ImageMagick v6:

convert -size 800x600 xc:transparent -fill white -stroke black -strokewidth 20 -draw "roundRectangle 50,100,600,500 32,33" output.png

But how do you draw a rounded rectangle with transparent fill over an existing image? (Only drawing the outside borders, no filling of the insides.)

Input image: enter image description here

Desired output image: enter image description here


Solution

  • Here is how to draw round rectangle on transparency in Imagemagick 6. The draw command has 3 arguments: top-left corner, bottom-right corner, corner radii.

    convert -size 500x500 xc:transparent -fill transparent -stroke black -strokewidth 10 -draw "roundrectangle 100,100 399,399 30,30" roundrectangle.png
    

    enter image description here

    See https://imagemagick.org/Usage/draw/#primitives