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
In PHP, How to Call a Function Interpolated in String
How to Convert Multiple <Br/> Tag to a Single <Br/> Tag in PHP
How to Get Random Image from Directory Using PHP
Convert a String to a Double - Is This Possible
Mysql_Connect VS MySQL_Pconnect
Split an Array into N Arrays - PHP
Shell Run/Execute PHP Script with Parameters
How to Call a Static Method from a Class If All I Have Is a String of the Class Name
How to Get the Server Path to the Web Directory in Symfony2 from Inside the Controller
How to Determine Whether It's a Mobile Device with PHP
Laravel Eloquent Compare Date from Datetime Field
Generate Download File Link in PHP
How to Force Page Not to Be Cached in PHP
How to Eliminate PHP5 Strict Standards Errors
How to Move an Array Element with a Known Key to the End of an Array in PHP