Page 1 of 1

Draw multiple rectangles with single command

Posted: 2014-05-27T12:06:51-07:00
by Wanderer
hi ,

I want to draw multiple colored rectangle in my image using the -draw command. I can use the below command to draw one rectangle/command. Is there any way possible to draw more than one rectangle in single command.

Code: Select all

convert Image1.jpg -fill black -draw "rectangle 135,55 155,60" Image2.jpg
I am on Windows using ImageMagick-6.8.9-Q16.

Re: Draw multiple rectangles with single command

Posted: 2014-05-27T12:42:44-07:00
by snibgo

Code: Select all

convert Image1.jpg -fill black -draw "rectangle 135,55 155,60 rectangle 235,155 255,160 rectangle 335,255 355,260 rectangle 435,355 455,360" Image2.jpg
Etc.
If you have a huge number of rectangles, you can put them in a file, eg rect.txt ...

Code: Select all

rectangle 135,55 155,60
rectangle 235,155 255,160
rectangle 335,255 355,260
rectangle 435,355 455,360
... and run the command:

Code: Select all

convert Image1.jpg -fill black -draw @rect.txt Image3.jpg
But I suggest you don't use jpeg format for solid colours like this. Png is usually more suitable.

Re: Draw multiple rectangles with single command

Posted: 2014-05-27T13:10:02-07:00
by Wanderer
Thanks snibgo