PHP - Create Simple Animated Gif from Two Jpeg Images

PHP - Create simple animated GIF from two JPEG images?

It's not possible using the standard GD functions that come pre-packed with PHP.

There is a class on phpclasses.org for this. I have never used it myself, but it's used by a lot of other packages.

Alternatively, if you have access to ImageMagick from PHP, using either the MagickWand library or the command line, use it. With ImageMagick, it's no problem.

  • ImageMagick v6 Animation basics (from the IM manual)

  • Creating an Animated GIF image

Create animated gif using the GD library

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

Create an animated .gif from .jpeg/png

There is a good post about it on SO : Create Animated Gif with Jpeg Images

You can't do it with GD Functions, but there is a class on phpclasses.org to do this, check that : PHP Classes GIF Animation From

You can also find a good tutorial about it here : Tutorial Generate Animated GIF PHP

How to extract frames of an animated GIF with PHP

I spent my day creating a class based on this one to achieve what I wanted using only PHP!

You can find it here: https://github.com/Sybio/GifFrameExtractor

Thanks for your answers!

How to create an animated GIF from JPEGs in Android (development)

See this solution.

https://github.com/nbadal/android-gif-encoder

It's an Android version of this post.

http://www.jappit.com/blog/2008/12/04/j2me-animated-gif-encoder/

To use this class, here is an example helper method to generate GIF byte array. Note here the getBitmapArray() function is a method to return all the Bitmap files in an image adapter at once. So the input is all the Bitmap files in one adapter, the output is a byte array which you can write to the file.

public byte[] generateGIF() {
ArrayList<Bitmap> bitmaps = adapter.getBitmapArray();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
AnimatedGifEncoder encoder = new AnimatedGifEncoder();
encoder.start(bos);
for (Bitmap bitmap : bitmaps) {
encoder.addFrame(bitmap);
}
encoder.finish();
return bos.toByteArray();
}

To use this function, do the following then you can save the file into SDcard.

FileOutputStream outStream = null;
try{
outStream = new FileOutputStream("/sdcard/generate_gif/test.gif");
outStream.write(generateGIF());
outStream.close();
}catch(Exception e){
e.printStackTrace();
}


Related Topics



Leave a reply



Submit