PHP / ImageMagick - Animate on the Fly

The following code will take two images and make an animated gif on the fly using ImageMagick.

PHP:
<?

//FULL PATH TO WHERE YOU WANT TO SAVE
$path = "/home/hsphere/local/home/USERNAME/yoursite.com/images/";

//THE COMMAND TO MAKE THE ANIMATION HAPPEN add more images if ya need to
$cmd = "/usr/local/bin/convert -dispose none -delay 20 FIRSTIMAGE.gif -delay 20 SECONDIMAGE.gif -loop 0 $path/animatedimage.gif"; 


//EXECUTE THE COMMAND AND CAPTURE ANY ERRORS
exec("$cmd 2>&1", $err); 

foreach($err as $errline){ 
 echo("$errline<br>"); 
}

?>
<!--display the animated image-->
<img src='animatedimage.gif'>
 
Back
Top