basic animated gif help

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
the1bullet

basic animated gif help

Post by the1bullet »

having some difficulty creating a very basic animated gif. I'd just like to create a gif that repeatedly cycles between two frames. my code so far looks like this.

Code: Select all

$img1 = NewMagickWand();
MagickReadImage( $img1, $location1 );
MagickSetImageDelay( $img1, 200);

$img2 = NewMagickWand();
MagickReadImage( $img2, $location2 );
MagickSetImageDelay( $img2, 200);

$final = NewMagickWand();
MagickAddImage($final,$img1);
MagickAddImage($final,$img2);

MagickSetFormat($final, 'GIF');
header('Content-Type: ' . MagickGetMimeType($final));
MagickEchoImagesBlob($final);
This creates a gif that cycles between img1 and img2 only once. How do I get it to repeat?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: basic animated gif help

Post by anthony »

Set loop to 0.


There is also a MagickCore function and now command line otpion to 'reverse' an image sequence (list). That clous emake patrol cycled animations easier...

See IM Examples, Reverse an animation.
http://www.imagemagick.org/Usage/animations/#reverse
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
the1bullet

Re: basic animated gif help

Post by the1bullet »

How would I set loop to zero with MagickWand for PHP? None of the functions seem to obviously allow a setting for loop. I'm trying to avoid using the command line.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: basic animated gif help

Post by anthony »

In perl magic you would

$image->Set(iterations=>0);

I don't know how this is done in Magick Wand however.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
the1bullet

Re: basic animated gif help

Post by the1bullet »

Thanks very much! Here's the answer: MagickSetImageIterations.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: basic animated gif help

Post by anthony »

Good to hear.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Aniruddha

Re: basic animated gif help

Post by Aniruddha »

_
sorry by mistake I have posted this here
Post Reply