PHP | Imagick montageImage() Function
Last Updated :
04 Dec, 2019
The Imagick::montageImage() function is an inbuilt function in PHP which is used to create a composite image by combining the many separated images. This function composite the images into the tiles form with the name of image optionally.
Syntax:
Imagick Imagick::montageImage( ImagickDraw $draw, string $tile_geometry,
string $thumbnail_geometry, int $mode, string $frame )
Parameters: This function accepts five parameters as mentioned above and described below:
- $draw: It specifies the font name, size, and color.
- $tile_geometry: It specifies the number of tiles per row and page.
- $thumbnail_geometry: It specifies the preferred image size and border size of each thumbnail.
- $mode: It contains an integer value corresponding to one of MONTAGEMODE constants.
- $frame: It specifies whether surrounds the image with an ornamental border.
List of all MONTAGEMODE constants are given below:
- imagick::MONTAGEMODE_FRAME (1)
- imagick::MONTAGEMODE_UNFRAME (2)
- imagick::MONTAGEMODE_CONCATENATE (3)
Return Value: This function returns a new Imagick object on success.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::montageImage() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$result = $imagick ->montageImage( new ImagickDraw(), '4x2' ,
'150x100+2+2' , imagick::MONTAGEMODE_UNFRAME, "2x2+3+3" );
$result ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $result ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newimage(1000, 800, 'green' );
$imagick ->labelImage( 'green' );
$imagick ->addImage( new imagick(
$imagick ->labelImage( 'Image1' );
$imagick ->addImage( new imagick(
$imagick ->labelImage( 'Image2' );
$imagick ->newimage(1000, 800, 'blue' );
$imagick ->labelImage( 'blue' );
$imagick ->newimage(1000, 800, 'violet' );
$imagick ->labelImage( 'violet' );
$imagick ->newimage(1000, 800, 'cyan' );
$imagick ->labelImage( 'cyan' );
$result = $imagick ->montageImage( new ImagickDraw(), "3x2+0+0" ,
"200x160+3+3>" , Imagick::MONTAGEMODE_CONCATENATE, "10x10+2+2" );
$result ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $result ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.montageimage.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...