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(100, 100);
/*** Set virtual canvas size to 100x100 ***/
$frame->setImagePage(100, 100, 0, 0);
}
/*** Write image to disk. Notice writeImages instead of writeImage ***/
$animation->writeImages("animation_thumbnail.gif");
echo "Images written";
}
catch(Exception $e)
{
echo $e->getMessage();
}
?>
try
{
/*** Read in the animated gif ***/
$animation = new Imagick("animation.gif");
/*** Loop through the frames ***/
foreach ($animation as $frame)
{
/*** Thumbnail each frame ***/
$frame->thumbnailImage(100, 100);
/*** Set virtual canvas size to 100x100 ***/
$frame->setImagePage(100, 100, 0, 0);
}
/*** 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