You are not logged in.

#1 2019-04-15 22:25:27

GOKOP
Member
Registered: 2018-04-29
Posts: 51

[SOLVED] Drawing with ImageMagick - confused rectangle pos and size

I'm trying to script something with imagemagick. When I run this command:

magick mogrify -fill "rgba(0,0,0,0.5)" -draw "rectangle 20,55 300,870" eee.png

A rectangle is drawn at position 20,55 with the size of 300,870, as I'd expect. However, upon issuing this command:

magick mogrify -fill "rgba(0,0,0,0.5)" -draw "rectangle 1700,920 200,140" eee.png

A rectangle is drawn at the position of 200,140 with the size of 1700,920. So the oposite of what happened before. What's more though, when I swap values the result doesn't change. So basically imagemagick doesn't let me create a rectangle at the position of 1700,920 with the size of 200,140, and that's what I need to do. Image eee.png is 1920x1080.

Last edited by GOKOP (2019-04-15 22:55:47)

Offline

#2 2019-04-15 22:47:22

frostschutz
Member
Registered: 2013-11-15
Posts: 1,653

Re: [SOLVED] Drawing with ImageMagick - confused rectangle pos and size

not tested, but

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

says

> rectangle    x0,y0 x1,y1

> A rectangle primitive is specified by the pair of points at the upper left and lower right corners.

these numbers are not size. they are absolute coordinates.

so rectangle 1700,920 200,140 should be a rectangle between the point P(200,140) and P(1700,920) and if you exchange them it remains the same.

> A rectangle is drawn at position 20,55 with the size of 300,870, as I'd expect.

size should be 281x816

Last edited by frostschutz (2019-04-15 22:50:14)

Offline

#3 2019-04-15 22:55:33

GOKOP
Member
Registered: 2018-04-29
Posts: 51

Re: [SOLVED] Drawing with ImageMagick - confused rectangle pos and size

Oh, that makes sense. So the first rectangle must've been smaller than 300x870 size but I didn't notice because I just saw it's in the right place.
It indeed works as you said, thank you

Offline

Board footer

Powered by FluxBB