Driving me up the wall trying to make a rectangle!

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ultranerds
Posts: 41
Joined: 2009-02-12T02:05:15-07:00

Driving me up the wall trying to make a rectangle!

Post by ultranerds »

Hi,

I know I'm gonna get a lot of stick for this, but I'm really struggling trying to get a rectangle made over an image. So far I have read this page:

http://www.imagemagick.org/script/comma ... .php?#draw

From what I understand about the co-ordinate system, I need:

convert ./wintercard1.jpg -fill white -stroke black -draw "rectangle 0,0 50,600 gravity South" ./wintercard1_new3.jpg

However, that makes a vertical (600px high, 50px wide) rectangle. My rectangle needs to be at the base of the image, and 50 high + 600 wide. Can someone suggest what I'm doing wrong? Maybe I'm mis-understanding how the coordinates system works?

TIA!

Andy
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Driving me up the wall trying to make a rectangle!

Post by Bonzo »

In your code: 0,0 = rectangle top left corner 50,600 = bottom righthand corner so you are getting what you as for; try -draw "rectangle 0,0 600,50 gravity South". I do not know if gravity has any effect in the draw command.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Driving me up the wall trying to make a rectangle!

Post by fmw42 »

Bonzo wrote:In your code: 0,0 = rectangle top left corner 50,600 = bottom righthand corner so you are getting what you as for; try -draw "rectangle 0,0 600,50 gravity South". I do not know if gravity has any effect in the draw command.

you probably need to put -gravity south outside and before the -draw command
ultranerds
Posts: 41
Joined: 2009-02-12T02:05:15-07:00

Re: Driving me up the wall trying to make a rectangle!

Post by ultranerds »

Hi,

Thanks for the replies guys. The box is the right size now, but the damn thing is refusing to draw at the bottom of the image :/

Code: Select all

convert ./wintercard1.jpg -fill white -stroke black -gravity south -draw "rectangle 0,0 600,50" ./wintercard1_new3.jpg
I've also tried "South" (ie uppercase S)... and that doesn't work either :(

TIA

Andy
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Driving me up the wall trying to make a rectangle!

Post by Bonzo »

I still do not know if you can use -gravity with draw as it is referancing the top left corner.

This will work:

Code: Select all

convert ./wintercard1.jpg ( -size 598x48 xc:white -bordercolor black -border 1x1 ) -gravity south -composite wintercard1_new3.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Driving me up the wall trying to make a rectangle!

Post by fmw42 »

I can confirm that

convert logo: -fill red -stroke black -gravity southeast -draw "rectangle 0,0 100,100" show:

does not honor -gravity.

I think -gravity is only sensitive in the following context for -draw

http://www.imagemagick.org/Usage/layers/#draw

So using -composite as Bonzo said is likely the best way.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Driving me up the wall trying to make a rectangle!

Post by anthony »

gravity only effects text and image placement (and justification! - sic). It is not part of SVG so is not really used for other primitive draw commands.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply