Page 1 of 1

Using variables with convert circle?

Posted: 2007-12-12T05:08:10-07:00
by simmo512
I can draw a circle fine using:-

-fill blue -draw 'circle 20,200 32,212'

but if I try to use variables below in a bash shell script its fails with "non-conforming drawing primitive definition `circle' ".

-fill blue -draw 'circle "$ax",200 $ay,212'

It looks like its a combination of using the right '"` around the variable. Can anyone suggest the correct combination?

Thanks in advance...

Simmo.
:D

Re: Using variables with convert circle?

Posted: 2007-12-12T05:19:29-07:00
by simmo512
TYPO in code, that should have been...

I can draw a circle fine using:-

-fill blue -draw 'circle 20,200 32,212'

but if I try to use variables below in a bash shell script its fails with "non-conforming drawing primitive definition `circle' ".

-fill blue -draw 'circle "$ax",200 "$ay",212'

It looks like its a combination of using the right '"` around the variable. Can anyone suggest the correct combination?

Thanks in advance...

Simmo.

Re: Using variables with convert circle?

Posted: 2007-12-12T05:36:38-07:00
by simmo512
Why is it you always work out the answer shortly after posting after having spent hours on the problem?

The answer is...

-fill blue -draw "circle $ax,200 $ay,212"

I just needed to replace the single quote e.g ' with double quotes around the whole circle command.

Hope this helps someone else...

Simmo :lol:

Re: Using variables with convert circle?

Posted: 2007-12-12T20:39:16-07:00
by anthony
simmo512 wrote:Why is it you always work out the answer shortly after posting after having spent hours on the problem?
because in writing out the problem for someone else you get a different point of view which suddenly makes you see the cause of the problem!!!

Re: Using variables with convert circle?

Posted: 2007-12-14T14:58:38-07:00
by maceis
Hello together,

I can't figure out which values I have to use for x0,y0 x1,y1 to draw a circle of a defined size.
I often get circles that are somehow cut off.
E.g I want to draw a circle with a radius of 8 and the center at 23,30. I tried:

Code: Select all

convert -size 120x60 xc:none \
-fill '#aaa' \
-draw 'circle 23,30 23,38' \
x:
The same with "-draw 'circle 23,30 31,30'"

I have read http://www.imagemagick.org/script/comma ... s.php#draw but that doesn't provide very much information. I'd be glad if someone could explain or provide a link to an explanation.

Thanks in advance and best regards
maceis

Re: Using variables with convert circle?

Posted: 2007-12-14T15:07:37-07:00
by el_supremo
The method you were using to create a circle is correct. If the circle is getting cut off then something else is wrong.
Can you give an example command and the resulting image? And which version of ImageMagick are you using?

Pete

Re: Using variables with convert circle?

Posted: 2007-12-14T15:22:56-07:00
by maceis
My Version is: ImageMagick 6.3.7

When saving the result of the above command as png-file I saw, that the resulting circle is not cut off.
Only in x: it looks like an octagon.

Anyhow. I am not sure what the x0,y0 x1,y1 values really are.
I think x0,y0 are the coordinates of rhe center of the circle.
Can x1,y1 be any point on the diameter of the circle?

Re: Using variables with convert circle?

Posted: 2007-12-14T16:27:26-07:00
by el_supremo
Can x1,y1 be any point on the diameter of the circle?
It's a point on the circumference (I presume that's what you meant).

Pete

Re: Using variables with convert circle?

Posted: 2007-12-15T02:08:49-07:00
by maceis
Yes, Thank you very much.

Re: Using variables with convert circle?

Posted: 2007-12-15T02:13:06-07:00
by Bonzo
When I tried your code I also created a Octogen. It only happens if I save to jpg; if I save to png its OK.
This must be due to jpg not supporting transparency.

Re: Using variables with convert circle?

Posted: 2007-12-15T09:25:01-07:00
by el_supremo
I tried that with the command line. This produces an octagon:

Code: Select all

convert -size 120x60 xc:none -fill #aaa -draw "circle 23,30 23,38" circle.jpg
But changing only the colour of the input image produces a circle:

Code: Select all

convert -size 120x60 xc:black -fill #aaa -draw "circle 23,30 23,38" circle.jpg
It's very strange that the transparency has such an effect.

Pete

Re: Using variables with convert circle?

Posted: 2007-12-15T09:35:48-07:00
by maceis
Yes. And it is also strange that X-Windows can handle transparency when you open files with transparency (e.g png files) but not when you specify x: as filename.

Re: Using variables with convert circle?

Posted: 2007-12-16T21:43:44-07:00
by anthony
There are other ways of drawing circles and even ellipses. some are center basied, other arc based, or even path basied. See IM Examples, Drawing for all the primatives and SVG path methods.