Display the image without saving to a file
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="sunflower.jpg";
$cmd = "convert $photo -thumbnail 200x200 ".
" -unsharp 0.2x0.6+1.0 -quality 100 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);
?>