Page 1 of 1

Animated gif resize

Posted: 2008-01-11T21:21:09-07:00
by Ominous
Greetings :)

I've just started using Imagick and I'm writing image preview script.
Here is a part of code:

Code: Select all

$img_path = $_SERVER['DOCUMENT_ROOT'].'/images/themes/my_img.jpg';
$image = new Imagick($img_path);
$type = $image->getFormat();
$image->thumbnailImage(200, 0);
header('Content-type: '.$type);
echo $image;
This is good when script is provided with jpg/png... but animated gif is problem.
Only first frame is resized :)
Could ony1 show me how ti loop trough all frames and output animated image?
tnx in advance

Re: Animated gif resize

Posted: 2008-01-12T10:57:28-07:00
by mkoppanen
Try this

Code: Select all

$im = new Imagick( "test.gif" );

foreach ( $im as $frame )
{
  $frame->thumbnailImage( 200, 0 );
  $frame->setImagePage( $frame->getImageWidth(), $frame->getImageHeight(), 0, 0 );
}

header( "Content-Type: image/gif" );
echo $im->getImagesBlob();


Re: Animated gif resize

Posted: 2008-01-12T17:13:50-07:00
by Ominous
Tnx for replay,
works gr8