Page 1 of 1

Draw rectangle (non filled)

Posted: 2010-09-29T14:29:08-07:00
by galv
I want to draw a rectangle at given coordinates but not filled, just the outline. How can I do this?

Re: Draw rectangle (non filled)

Posted: 2010-09-29T14:43:55-07:00
by el_supremo
Use a transparent fill. e.g.:

Code: Select all

convert logo: -fill none -stroke black -strokewidth 3 -draw "rectangle 10,10 630,470" logo_rect.png
Pete

Re: Draw rectangle (non filled)

Posted: 2010-09-29T15:29:33-07:00
by galv
Thank you for that. Is there a way to create more than one rectangles at different areas of the image (except from the obvious, calling convert more than once)? If yes, how?

Re: Draw rectangle (non filled)

Posted: 2010-09-29T15:57:02-07:00
by fmw42
I believe you can call several rectangles with the same -draw (in the quotes), but for sure you can string draw commands together in the same command line.

see http://www.imagemagick.org/Usage/draw/

Re: Draw rectangle (non filled)

Posted: 2010-09-29T19:22:25-07:00
by anthony
You can either use multiple -draw commands on the same image, OR repeat the rectangle (or other draw MVG commands) in the same draw command string.
http://www.imagemagick.org/Usage/draw/#intro

You can also write all your MVG draw commands into a file and simply read that file as a draw command string, or as an image in its own right!
http://www.imagemagick.org/Usage/draw/#reading
Anthony Thyssen wrote:There are lots of ways to skin a cat, and what method you use depends
on what you want that skin for, and how messy you like the results!

Re: Draw rectangle (non filled)

Posted: 2010-10-06T07:04:10-07:00
by galv
Thanks for that, it worked.
Now I want to circle the same area so I'm using -draw circle with the same coordinates as region, but the result makes a circle larger than the area expected. Is there a calculation formula that I can use to bring it down to the correct region?

Re: Draw rectangle (non filled)

Posted: 2010-10-06T13:49:02-07:00
by fmw42
galv wrote:Thanks for that, it worked.
Now I want to circle the same area so I'm using -draw circle with the same coordinates as region, but the result makes a circle larger than the area expected. Is there a calculation formula that I can use to bring it down to the correct region?
circle wants two points, the center and a point on the perimeter of the circle. So if you want a circle to pass through the corners of the rectangle, then you need to find the center of the rectangle and use one point at the corner. If you want the circle to be tangent to two sides or 4 sides if a square, then you need the center of the rectangle and the center of one side of the rectangle.

see http://www.imagemagick.org/Usage/draw/#circles

Re: Draw rectangle (non filled)

Posted: 2010-10-06T21:07:25-07:00
by anthony
You can also use arc which defines the 'circle' in terms of a bounding rectangle.
See Draw primatives
http://www.imagemagick.org/Usage/draw/#primitives