Page 1 of 1
how to draw a rectangle with 100% width?
Posted: 2009-10-09T06:43:34-07:00
by roach
I'm trying to draw a rectangle on an existing image, such that the rectangle is flush with the top of the image, and covers 100% of the width of the image.
Something like:
convert inputFile.jpg -fill white -stroke white -draw "rectangle 0,0 100%,20" output.jpg
Of course that doesn't work, but can anyone tell me how I might accomplish this?
Re: how to draw a rectangle with 100% width?
Posted: 2009-10-09T07:33:29-07:00
by Bonzo
You can use fx to find the width of the image; this would have to be saved into a variable then use the variable in the command that you have.
Re: how to draw a rectangle with 100% width?
Posted: 2009-10-09T09:14:20-07:00
by roach
Nevermind. I ended up using a combination of -chop and -splice instead. Worked for what I needed.
Re: how to draw a rectangle with 100% width?
Posted: 2009-10-11T19:43:51-07:00
by anthony
NOTE the rectangle size is also effecting not just by the pixel dimentions given, but also the stroke width used.
One example of generating a rectangle to a specific image was exampled in IM Examples, Thumbnails,
Border with Rounded Corner
Part of that example is enlarging the final image size slightly so as to minimise the amount of image that gets covered up by the added border.
However the -chop or -shave with a -splice or -border method is probably easiest.
See cutting and bordering...
http://www.imagemagick.org/Usage/