Monday, 3 February 2014

Create Thumbnail From Animated GIF


Create Thumbnail From Animated GIF

<?php
try
{
    
/*** Read in the animated gif ***/
    
$animation = new Imagick("animation.gif");

    
/*** Loop through the frames ***/
    
foreach ($animation as $frame)
    {
        
/*** Thumbnail each frame ***/
        
$frame->thumbnailImage(100100);
   
        
/*** Set virtual canvas size to 100x100 ***/
        
$frame->setImagePage(10010000);
    }

    
/*** Write image to disk. Notice writeImages instead of writeImage ***/
    
$animation->writeImages("animation_thumbnail.gif");

    echo 
"Images written";
}
catch(
Exception $e)
{
    echo 
$e->getMessage();
}
?>

No comments:

Post a Comment