is there a way to draw circles with command?
Posted: 2009-03-16T21:50:06-07:00
I want to know how can I write command to draw circle with given center,radius & colour in a particular image.
Use https://github.com/ImageMagick/ImageMagick/discussions instead.
https://download.imagemagick.org/discourse-server/
https://download.imagemagick.org/discourse-server/viewtopic.php?t=13345
Code: Select all
<?php
exec("convert -size 200x200 xc:black -stroke black -strokewidth 1 \\
-fill white -draw \"circle 100,100 100,10 \" \\
-fill black -draw \"circle 100,100 100,30 \" \\
-fill blue -draw \"circle 100,100 100,50 \" \\
-fill red -draw \"circle 100,100 100,70 \" \\
-fill yellow -draw \"circle 100,100 100,90 \" \\
-fill none -draw \"circle 100,100 100,20 \" \\
-fill none -draw \"circle 100,100 100,60 \" \\
-fill none -draw \"circle 100,100 100,80 \" \\
-fill none -draw \"circle 100,100 100,95 \" \\
-stroke white -fill none \\
-draw \"circle 100,100 100,40 \" circle.png");
?>
Code: Select all
@rem Draw a circle on the specified image
@rem several assumptions are made about the input image to simplify
@rem this script, in particular it is assumed that the image is 640x480
@rem but with more programming the script can be made much more flexible
@rem compute the x coordinate of a point on the circumference of the circle
set /A rad=320+%1
@rem the colour of the circle depends upon its radius
set /A colour=255-%1
imconvert %2 -fill rgb(%colour%,255,127) -draw "circle 320,240 %rad%,240" %2
Code: Select all
@rem create the base image
imconvert logo: logo_base.gif
@rem now draw concentric coloured circles on it
FOR /L %%A IN (120,-10,10) DO call draw_circle %%A logo_base.gif
Code: Select all
for_circle
Code: Select all
@rem Write a sub-command to draw a circle
@rem several assumptions are made about the input image to simplify
@rem this script, in particular it is assumed that the image is 640x480
@rem but with more programming the script can be made much more flexible
@rem compute the x coordinate of a point on the circumference of the circle
set /A rad=320+%1
@rem the colour of the circle depends upon its radius
set /A colour=255-%1
@rem It is CRUCIAL that there is NOT a space after the continuation symbol ^^ so
@rem there is NO space between the continuation and the redirection
echo -fill rgb(%colour%,255,127) -draw ^"circle 320,240 %rad%,240^" ^^>>logo_loop.bat
Code: Select all
echo imconvert logo: >logo_loop.bat ^^
FOR /L %%A IN (120,-10,10) DO call draw_loop %%A
echo logo_loop.gif>>logo_loop.bat
rem now execute the script we've just built
logo_loop
Code: Select all
for_loop
Code: Select all
imconvert logo: ^
-fill rgb(135,255,127) -draw "circle 320,240 440,240" ^
-fill rgb(145,255,127) -draw "circle 320,240 430,240" ^
-fill rgb(155,255,127) -draw "circle 320,240 420,240" ^
-fill rgb(165,255,127) -draw "circle 320,240 410,240" ^
-fill rgb(175,255,127) -draw "circle 320,240 400,240" ^
-fill rgb(185,255,127) -draw "circle 320,240 390,240" ^
-fill rgb(195,255,127) -draw "circle 320,240 380,240" ^
-fill rgb(205,255,127) -draw "circle 320,240 370,240" ^
-fill rgb(215,255,127) -draw "circle 320,240 360,240" ^
-fill rgb(225,255,127) -draw "circle 320,240 350,240" ^
-fill rgb(235,255,127) -draw "circle 320,240 340,240" ^
-fill rgb(245,255,127) -draw "circle 320,240 330,240" ^
logo_loop.gif
Code: Select all
convert bungalow.jpg -resize 50x50 small_bungalow.png
Code: Select all
convert %1 -resize 50x50 resized_%1
Code: Select all
convert %1 -resize 50x50 resized_%2
On my system, "convert" clashes with the Windows convert command so I made a copy of the ImageMagick convert.exe and renamed it to imconvert.exe so that I don't have any confusion over which one I'm using. And I forgot to change it back to convert when I posted itBoth examples fail with something like 'imconvert' is not recognised
This script will resize its input argument and write it as a png with "resized_" prepended to the name.Could I run my resize.bat file something like "resize bungalow.jpg"
Code: Select all
convert %1 -resize 50x50 "%~p1resized_%~n1.png"
Code: Select all
@ECHO OFF
:: Set some variables
SET INPUTFILE=%1
FOR /F %%x IN ('identify -format "%%[EXIF:DateTime]" %INPUTFILE%') DO SET DateTime=%%x
:: Add the date photo taken to the image
convert %INPUTFILE% -pointsize 18 -fill black -gravity northwest ^
-annotate +0+0 "Date: %DateTime%" watermarked_%INPUTFILE%