The Imagick::smushImages() function is an inbuilt function in PHP which is used to take all the images from the list of current image to the end of the image and smush them to each other from top-to-bottom if the stack parameter is set to true, otherwise left-to-right.
Syntax:
bool Imagick::smushImages(bool $stack, int $offset)
Parameters: This function accepts two parameters as mentioned above and described below:
- $stack: This parameter holds the boolean which decides whether to smush top-to-bottom which is in case of TRUE or left-to-right which is in case of FALSE.
- $offset: This parameter holds the mean offset.
Return Value: This function returns a new smushed image.
Below programs illustrates the Imagick::smushImages() function in PHP:
Program 1:
<?php // Create a new Imagick object $imagick1 = new Imagick( // Create another new Imagick object $imagick2 = new Imagick( // Add the image $imagick1->addimage($imagick2); // Apply the smushImages() function $smushed = $imagick1->smushImages(false, 100); header("Content-Type: image/png"); // Display the output image echo $smushed->getImageBlob(); ?> |
Output:

Program 2:
<?php // Create a new Imagick object $imagick1 = new Imagick( // Create another new Imagick object $imagick2 = new Imagick( // Add the image $imagick1->addimage($imagick2); // Apply the smushImages() function $smushed = $imagick1->smushImages(true, 70); header("Content-Type: image/png"); // Display the output image echo $smushed->getImageBlob(); ?> |
Output:

Reference: https://www.php.net/manual/en/imagick.smushimages.php
Recommended Posts:
- PHP | Imagick floodFillPaintImage() Function
- PHP | Imagick adaptiveSharpenImage() Function
- PHP | Imagick flopImage() Function
- PHP | Imagick setImageExtent() Function
- PHP | Imagick getImageWhitePoint() Function
- PHP | Imagick getCompressionQuality() Function
- PHP | Imagick clear() Function
- PHP | Imagick annotateImage() Function
- PHP | Imagick adaptiveResizeImage() Function
- PHP | Imagick adaptiveBlurImage() Function
- PHP | Imagick adaptiveThresholdImage() Function
- PHP | Imagick addNoiseImage() Function
- PHP | Imagick colorizeImage() Function
- PHP | Imagick addImage() Function
- PHP | Imagick setImageDispose() Function
- PHP | Imagick borderImage() Function
- PHP | Imagick getImageMatte() Function
- PHP | Imagick getImageMimeType() Function
- PHP | Imagick getImageRenderingIntent() Function
- PHP | imagick getImageDispose() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.

