With PHP, is it possible to combine animated gifs with jpg and save gifs animations?

Using PHP (GD or ImageMagick) I want to combine an animated gif with jpg and save the gif animation, and the product is an animated gif.

In other words, I have an animated gif whose size is 500px x 30px and it needs to lie on top of a jpg of 500px x 500px, the end result of which is a single animated gif.

So, does anyone know if it is possible to combine an animated gif with jpg and save the gifs animation?

+6
source share
1 answer

See the Imagick Method :: animateImages , sample gomadurai:

<?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 in a folder, and then combine the individual images using a simple manipulation of GD (one of the comments here ), and after using the code above to create a new Gif.

+1
source

Source: https://habr.com/ru/post/902958/


All Articles