Using variables with convert circle?

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
simmo512

Using variables with convert circle?

Post 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
simmo512

Re: Using variables with convert circle?

Post 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.
simmo512

Re: Using variables with convert circle?

Post 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:
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Using variables with convert circle?

Post 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!!!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
maceis

Re: Using variables with convert circle?

Post 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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Using variables with convert circle?

Post 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
maceis

Re: Using variables with convert circle?

Post 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?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Using variables with convert circle?

Post 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
maceis

Re: Using variables with convert circle?

Post by maceis »

Yes, Thank you very much.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Using variables with convert circle?

Post 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.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Using variables with convert circle?

Post 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
maceis

Re: Using variables with convert circle?

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Using variables with convert circle?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply