Writing IM code
<?php
$color = 'red';
$image = 'rose:';
$size = '70x46';
$string = 'A Rose by any Name';
// Example 1 - Using concatenate
exec("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 line
exec("convert -background none -fill $color -gravity center -font Candice -size $size caption:\"$string\" \( $image -negate -flip \) +swap -composite output.gif" );
?>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.