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.
Writing IM code - Anthony 15/6/2008
Below are some different ways you can write the IM code. I always used to use the exec( ); with everything on the same line and still do for short code. But with complicated code it makes it easyer to read if you use the $cmd version.
<?php$color = "red";$image = "rose:";$size = "70x46";$string = "A Rose by any Name";// Example 1 - Using concatenateexec("convert -background none -fill $color -gravity center " ." -font Candice -size $size caption:\"$string\" " ." \\( $image -negate -flip \\) +swap -composite " ." output.gif" );// Example 2 - Using the imagemagick line continuation of \// You need to escape the \ with another \ so it becomes \\exec("convert -background none -fill \'$color\' -gravity center \\-font Candice -size $size caption:\"$string\" \\\\( $image -negate -flip \\) +swap -composite \\output.gif" );// Example 3 - Writing the comand into a variable$cmd = "-background none -fill $color -gravity center " ." -font Candice -size $size caption:\"$string\" " ." \( $image -negate -flip \) +swap -composite ";exec("convert $cmd output.gif" );// Example 4 - One long lineexec("convert -background none -fill $color -gravity center -font Candice -size $size caption:\"$string\" \\( $image -negate -flip \\) +swap -composite output.gif" );?>
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