PHP | Imagick coalesceImages() Function

The Imagick::coalscaleImages() function is an inbuilt function in PHP which is used to combined the set of images into single image. It composites a set of images with respect to any page offsets and disposal methods. The animation sequences GIF, MIFF, and MNG are typically start with an image background and each subsequent image varies in size and offset.


Imagick Imagick::coalesceImages( void )

Parameters: This function does not accepts any parameters.

Return Value: It returns an Imagick object on success.

Below program illustrates the Imagick::coalscaleImages() function in PHP:

Program: This program generates an animated gif image from a set of images.





$images = [
// Loading up images in an array 
$temp = new Imagick();
foreach ($images as $image) {
// Reading each image with a delay
// of 100 millisecond time
$gif = $temp->coalesceImages();
// Composing set of all images
// Setting up output format to gif
// Infinite iterations of gif
header("Content-Type: image/gif");
// Display the image
echo $gif->getImagesBlob();


image file


My Personal Notes arrow_drop_up

Im a final year MCA student at Panjab University, Chandigarh, one of the most prestigious university of India I am skilled in various aspects related to Web Development and AI I have worked as a freelancer at upwork and thus have knowledge on various aspects related to NLP, image processing and web

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.