With most of my examples I save the output to a file; there may be a time when you do not want to do this but just display the image. You need a slightly different code to do this with php
This is a method suggested by a user on the ImageMagick forum
The code is saved on a page in this case called image.php; then you use the standard image call tags to call the page
<img src="image.php">
<?php
$photo="../code/sunflower.jpg";
$THUMB_SZ = 125;
$THUMB_PRESZ = $THUMB_SZ * 2;
$QUALITY = 87;
$cmd = "convert -size $THUMB_PRESZ".'x'."$THUMB_PRESZ \"$photo\"" .
" -resize $THUMB_SZ".'x'."$THUMB_SZ" .
" -strip" .
" -unsharp 0.2x0.6+1.0" .
" -quality $QUALITY JPG:-";
header("Content-type: image/jpeg");
passthru($cmd, $retval);
?>
Another way but there must be NO CODE before this code:
<?php
system("convert ../code/sunflower.jpg -resize 200x200 JPG:-");
Watermark an animated gif "On the fly".
<?php
$animation = "original.gif";
$watermark = "output.png";
$cmd = "convert $animation -coalesce -gravity Center -geometry +0+0
null: $watermark -layers composite -layers optimize GIF:-";
header("Content-type: image/gif");
passthru($cmd, $retval);
?>