Search code examples
phpgdanimated-gif

Create animated gif using the GD library


If I've got a bunch of image resources that I made using the GD library in php, or otherwise a bunch of frames, how can I combine these into an animated gif? I've got an array of images and a frames per second I'd like to add..

I can't use ImageMagick or FFMPEG, and I'd prefer to just use the GD library if possible.

Apparently "Support for creating GIF animations is also available.", but I can't seem to find the documentation on how to access this from within PHP?


Solution

  • Well searching on Google revealed GIFEncoder.class.php found at http://www.phpclasses.org/package/3163-PHP-Generate-GIF-animations-from-a-set-of-GIF-images.html
    This link requires registration.

    So i searched a little and it is included in phpvideotoolkit on code.google.com and can be downloaded at:
    http://phpvideotoolkit.googlecode.com/svn-history/r6/trunk/phpvideotoolkit/adapters/ffmpeg-php/gifencoder/GIFEncoder.class.php

    there is also a bugfixed version just change the file name to GIFEncoder.class.phpvideotoolkit.php in the above link.

    I haven't tried it myself but maybe it can help you.

    in the parent directory of the php file on code.google.com is also an example

    best of luck