Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Draw options

Arc

Draw an arc through 3 points.

Arc example
$cmd = "-size 213x160 xc:NavajoWhite -stroke black ". 
"-strokewidth 1 -fill none -draw \"arc 66,50 200,150 0,135 \" "; 
exec("convert $cmd arc.jpg");

Circle

Drawer a circle with the center and start point.

Circle example
$cmd = "-size 213x160 xc:NavajoWhite -stroke black ". 
"-strokewidth 1 -fill none -draw \"circle 106,80 106,10 \" "; 
exec("convert $cmd circle.jpg");

( Using -fill none draws the outline only. You can use -linewidth as well as -strokewidth. )

Line

Draw a line between two points

Line example
$cmd = "-size 213x160 xc:NavajoWhite -stroke black ". 
"-strokewidth 1 -fill none -draw \"line 50,50 163,110 \" "; 
exec("convert $cmd line.jpg");

Rectangle

Draw a rectangle from two oposing corners

Rectangle example
$cmd = "-size 213x160 xc:NavajoWhite -stroke black ". 
"-strokewidth 1 -fill none -draw \"rectangle 50,50 167,110 \" "; 
exec("convert $cmd rectangle.jpg");

Rounded rectangle

Draw a rectangle with rounded corners

Rounded rectangle example
$cmd = "-size 213x160 xc:NavajoWhite -stroke black ". 
"-strokewidth 1 -fill none ". 
"-draw \"roundRectangle 50,50 167,110 10,10 \" "; 
exec("convert $cmd round_rectangle.jpg");

Text

Draw text

Text example
$cmd = "$input -pointsize 40 -fill white ". 
"-gravity south -draw \" text 0,0 'Draw text' \" "; 
exec("convert $cmd text.jpg");