Search code examples
phpimageimagemagickimagick

Imagemagick create rectangles


I am trying to create rectangles like this:enter image description here

I tried following command:

convert -size 720x567 xc:black -stroke white -strokewidth 5 -draw "rectangle 100,200 300,350 " -draw "rectangle 65,55 45,95 " -draw "rectangle 80,55 90,95 " -draw "rectangle 95,55 105,95 " -draw "rectangle 110,55 120,95 " -draw "rectangle 125,55 135,50 " test.png

and it created me this:

enter image description here

Any tips of how to achieve this

I tried Mark Setchell suggestion:

convert -size 720x567 xc:black -stroke blue -strokewidth 5 \
   -draw "rectangle 50,300 230,450"                        \
   -draw "rectangle 250,300 430,450"                       \
   -draw "rectangle 450,300 630,450" test.png

But I get this :

enter image description here


Solution

  • Not sure why you expect to get blue boxes with a white stroke? I think you want something more like this:

    convert -size 720x567 xc:black -stroke blue -strokewidth 5 \
       -draw "rectangle 50,300 230,450"                        \
       -draw "rectangle 250,300 430,450"                       \
       -draw "rectangle 450,300 630,450" test.png
    

    enter image description here