PHP / ImageMagick - Animate on the Fly

Discussion in 'PHP or PERL Snips' started by doctorallia, Sep 19, 2005.

  1. doctorallia

    doctorallia Perch

    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'>

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services