is there a way to draw circles with command?

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?".
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

I thought each of R,G & B can vary from 0 to ff not ffff.

Post by manit »

(Q1)I thought each primary colour has 256 variations in intensity so range 0 to ff.Please clarify.

(Q2)What does alpha mean?

(Q3)my .bat file points to exe file in evry command like
"E:\software\image magick\ImageMagick-6.4.8-9\mogrify.exe" -stroke rgb(191,191,191) -fill rgb(191,191,191) -draw "circle 400,300 400,555" e:\circleseries.bmp
Can i write a script which mogrify can take as input

(Q4)I want to draw circle (on a picture)whose inside is completely transparent to allow the picture behind to be fully visible.
Last edited by manit on 2009-03-26T21:03:55-07:00, edited 2 times in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: is there a way to draw circles with command?

Post by Bonzo »

1 #00ff is shorthand for #00000000FFFFFFFF ?

2 Alpha is transparency

3 Why are you using mogrify ?

Code: Select all

"convert -stroke rgb(191,191,191) -fill rgb(191,191,191) -draw "circle 400,300 400,555" e:\circleseries.bmp
Above should work if your installation is correct - although you have not set a background/canvas size or colour.

4 Use -fill for the colour
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: is there a way to draw circles with command?

Post by el_supremo »

If you specify #00ff as a colour, IM will interpret it as a 4-bit RGBA colour so r=0,g=0,b=f,a=f. If you are using the Q16 version of IM, this will be expanded to R=0000, G=0000, B=ffff, A=ffff so it is #00000000ffffffff. The Q8 version would use r=00,g=00,b=ff,a=ff. If there had only been 3 hex digits IM would have interpreted it as 4-bit RGB.
If you specify 6 or 8 hex digits, IM interprets it as an 8-bit RGB (6 digits) or RGBA (8 digits) specification. Similarly, 12 or 16 hex digits are interpreted as 16-bit RGB or RGBA.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: is there a way to draw circles with command?

Post by el_supremo »

convert -stroke rgb(191,191,191) -fill rgb(191,191,191) -draw "circle 400,300 400,555" e:\circleseries.bmp
This should be:

Code: Select all

convert e:\circleseries.bmp -stroke rgb(191,191,191) -fill rgb(191,191,191) -draw "circle 400,300 400,555" e:\circleseries.bmp
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: is there a way to draw circles with command?

Post by manit »

Here is the image Image that I created on varying colour from #11ff to #ffff (i.e the first two characters were only changed).

QUESTION
(Q4 CLARIFIED)I meant that I want to draw circle whose inside is completely transparent so that when I draw it over a image then part of image inside circle is also visible.What should be command?
(Q3 CLARIFIED)By script I mean that does any command accept a script whose statements are sequentially applied over specified image.
Last edited by manit on 2009-03-26T21:34:16-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: is there a way to draw circles with command?

Post by fmw42 »

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: is there a way to draw circles with command?

Post by anthony »

Just turn off the fill color using the color 'none' and turn on the border or stroke color using the desired color.

Warning If a stroke color is given it will have a thickness that goes both into and out of the area that would normally be covered by fill. If it is not thick enough it may leave 'gaps' between successive circles. Better to fill the circles from outside in, so as to avoid any possible 'gaps' between colors.

For Expert Usage The circle radius is a floating point operation, so you can draw a circle that is say half a pixel smaller that another circle. You may be able to use that to overlay 'stroked' circles of 1 pixel thickness so as to avoid any 'gaps'.

The location of the circles center (or any other coordinate in drawing operations) are also floating point, but are offset by 0.5 units, so that integer locations align with the center of the corresponding pixel.

That is a circle centered at 10,10 is actually centered in the middle of the 10th pixel from the top and left edges, and as such is really located at 10.5,10.5 in image coordinates. This however is generally only important when converting between drawing coordinates and the coordinates used for image distortions.
A novice practices until he gets it right.
An expert practices until he doesn't get it wrong.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: is there a way to draw circles with command?

Post by fmw42 »

Sorry, accidentally posted twice. See next post.
Last edited by fmw42 on 2010-05-22T12:46:43-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: is there a way to draw circles with command?

Post by fmw42 »

manit wrote:I want to know how can I write command to draw circle with given center,radius & colour in a particular image.
This works to draw a circle at 50,50 with radius 30:

convert -size 100x100 xc:skyblue -fill white -stroke red -strokewidth 2 \
-draw "translate 50,50 circle 0,0 30" \
tmp_circle1.png
Image

you can also draw a (semi) ellipse using the two radii (30,20) and center at 50,50:

convert -size 100x100 xc:skyblue -fill white \
-draw "translate 50,50 rotate 45 ellipse 0,0 30,20 180,0" \
tmp_ellipse1.png
Image

Thanks to Anthony for helping to figure this out.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: is there a way to draw circles with command?

Post by anthony »

A whole host of circle drawing methods is given in IM Examples, Drawing on Images, Drawing Circles
http://www.imagemagick.org/Usage/draw/#circles

Some of these worked out by Fred (fmw42)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply