Snippets - Utilities
NOTE: Most of the IM snippets have been tested on IM version 6.3.5 There may be some differences if you are using the code on other versions.
Gravity option - Anthony 15/6/2008
The -gravity option is used to place the object in position. The object can be moved from the position set by gravity by using the geometry option as well e.g. -gravity Center -geometry +10+10
<?php$cmd = "-size 500x300 xc:white -font ../verdana.ttf -pointsize 30 "." -draw \"gravity center fill black text 0,0 \"Center\" \" "." -draw \"gravity North fill black text 0,0 \"North\" \" "." -draw \"gravity Northeast fill black text 0,0 \"Northeast\" \" "." -draw \"gravity East fill black text 0,0 \"East\" \" "." -draw \"gravity Southeast fill black text 0,0 \"Southeast\" \" "." -draw \"gravity South fill black text 0,0 \"South\" \" "." -draw \"gravity Southwest fill black text 0,0 \"Southwest\" \" "." -draw \"gravity West fill black text 0,0 \"West\" \" "." -draw \"gravity Northwest fill black text 0,0 \"Northwest\" \" "." -bordercolor black -border 1x1 " ;exec("convert $cmd output.png");// In this case I think a neater way of writting the code is using more php as below.// Array of values$arr = array("North", "Northeast", "East", "Southeast", "South", "Southwest", "West", "Northwest", "Center");// Set $command$command ="";// Setup loop for the arrayforeach ($arr as $value) {// Create the individual draw commands and add them to the previous value of $command$command .= " -draw \"gravity $value fill black text 0,0 $value \" " ; }// Create the image using phpexec(" convert -size 500x300 xc:white -font ../verdana.ttf -pointsize 30 $command bordercolor black -border 1x1 output.png" );//exec("convert $cmd output.png");?>

For more examples and information check out the main Imagemagick section.
Batch file ViewFonts installed View
Fonts Installed view View
Gravity option View
http image source View
Image information View
New image size in variable View
Path - find automaticly View
Path to Imagemagick View
Setup Information View
Shell script View
Variables in the code View
Version of Imagemagick installed View
Writing IM code View