Animated gif resize

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Ominous

Animated gif resize

Post 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
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: Animated gif resize

Post 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();

Mikko Koppanen
My blog: http://valokuva.org
Ominous

Re: Animated gif resize

Post by Ominous »

Tnx for replay,
works gr8
Post Reply