The Imagick::appendImages() function is an inbuilt function in PHP which is used to append set of images. This function appends a set of images into a single image.
Syntax:
Imagick::appendImages( $stack )
Parameters: This function accepts a single parameters $stack which is mandatory. If the stack value is false then images stacked from left to right and if the stack value is true then image stacked from top to bottom. The default value of the stack is false.
Return Value: This function returns Imagick instance on success.
Errors/Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::appendImages() function in PHP:
Program 1:
<?php
$image = new Imagick();
$image ->newImage(600, 70, "red" );
$image ->newImage(600, 70, "white" );
$image ->newImage(600, 70, "green" );
$image ->resetIterator();
$combined = $image ->appendImages(true);
$combined ->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $combined ;
?>
|
Output:

Program 2:
<?php
$image = new Imagick();
$image ->newImage(210, 200, "red" );
$image ->newImage(210, 200, "white" );
$image ->newImage(210, 200, "green" );
$image ->resetIterator();
$combined = $image ->appendImages(false);
$combined ->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $combined ;
?>
|
Output:

Related Articles:
Reference: http://php.net/manual/en/imagick.appendimages.php
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
26 Aug, 2019
Like Article
Save Article