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?
how to draw a rectangle with 100% width?
Re: how to draw a rectangle with 100% width?
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?
Nevermind. I ended up using a combination of -chop and -splice instead. Worked for what I needed.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: how to draw a rectangle with 100% width?
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/
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/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/