Using PHP (GD or ImageMagick) I want to merge an animated gif with a jpg and retain the animation of the gif, the product being an animated gif.
In other words, I've got an animated gif that is 500px x 30px and needs to lay on top of a jpg thats 500px x 500px, the end result being a single animated gif.
So again, anyone know if it's possible to merge an animated gif with a jpg and retain the gifs animation?
Look Imagick::animateImages method, gomadurai sample:
<?php
$multiTIFF = new Imagick();
$mytifspath = "./man"; // your image directory
$files = scandir($mytifspath);
//print_r($files);
/*foreach( $files as $f )
{*/
for($i=2;$i<6;$i++)
{
echo $files[$i];
echo "<br>";
$auxIMG = new Imagick();
$auxIMG->readImage($mytifspath."/".$files[$i]);
$multiTIFF->addImage($auxIMG);
}
//file multi.TIF
$multiTIFF->writeImages('multi423432.gif', true); // combine all image into one single image
//files multi-0.TIF, multi-1.TIF, ...
$multiTIFF->writeImages('multi.gif', false);
?>
If you use only one gif, you can save it splitted on a folder, then merge separated images with a simple GD manipulation (one of the comments here), and after use the code above to create the new Gif.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With