Open In App

PHP | Imagick montageImage() Function

Last Updated : 04 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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
  
// Create a new Imagick object
$imagick = new Imagick(
  
// Create a montage
$result = $imagick->montageImage(new ImagickDraw(), '4x2',
        '150x100+2+2', imagick::MONTAGEMODE_UNFRAME, "2x2+3+3");
  
// Display the image
$result->setImageFormat('png');
header("Content-Type: image/png");
  
echo $result->getImageBlob();
?>


Output:

Program 2:




<?php
  
// Create a new Imagick object
$imagick = new Imagick();
  
// Create a new Image with label
$imagick->newimage(1000, 800, 'green');
$imagick->labelImage('green');
  
// Add a new Image with label
$imagick->addImage(new imagick(
  
$imagick->labelImage('Image1');
  
// Add a new Image with label
$imagick->addImage(new imagick(
  
$imagick->labelImage('Image2');
  
// Create a new Image with label
$imagick->newimage(1000, 800, 'blue');
$imagick->labelImage('blue');
  
// Create a new Image with label
$imagick->newimage(1000, 800, 'violet');
$imagick->labelImage('violet');
  
// Create a new Image with label
$imagick->newimage(1000, 800, 'cyan');
$imagick->labelImage('cyan');
  
// Create a montage
$result = $imagick->montageImage(new ImagickDraw(), "3x2+0+0"
     "200x160+3+3>", Imagick::MONTAGEMODE_CONCATENATE, "10x10+2+2");
  
// Display the image
$result->setImageFormat('png');
header("Content-Type: image/png");
  
echo $result->getImageBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagick.montageimage.php



Similar Reads

PHP | Imagick floodFillPaintImage() Function
The Imagick floodFillPaintImage() Function is an in-built function in PHP which is used to change the color value of any pixel that matches the target, along with its immediate neighbor pixels of the same color. Note: This method is a replacement for deprecated Imagick::paintFloodFillImage() Function and is available if Imagick has been compiled ag
4 min read
PHP | Imagick adaptiveSharpenImage() Function
The Imagick::adaptiveSharpenImage() function is an inbuilt function in PHP which provides an adaptive sharpen image feature to the image. The intensity of an adaptive sharpen image depends on dramatically decreased at the edge of the image. Syntax: bool Imagick::adaptiveSharpenImage ( $radius, $sigma, $channel ) Parameters: This function accepts th
1 min read
PHP | Imagick flopImage() Function
The Imagick::flopImage() function is an inbuilt function in PHP which is used to create a horizontal mirror image. Syntax: bool Imagick::flopImage( void ) Parameters: This function does not accept any parameter. Return Value: This function returns True on success. Below programs illustrate the Imagick::flopImage() function in PHP: Program 1: Origin
1 min read
PHP | Imagick setImageExtent() Function
The Imagick::setImageExtent() function is an inbuilt function in PHP which is used to set the image size. This function doesn't scales the image but crops the unwanted parts. Syntax: bool Imagick::setImageExtent( int $columns, int $rows ) Parameters: This function accepts two parameters as mentioned above and described below: $columns: It specifies
1 min read
PHP | Imagick getImageWhitePoint() Function
The Imagick::getImageWhitePoint() function is an inbuilt function in PHP which is used to get the chromaticity white point of an Imagick object. Syntax: bool Imagick::getImageWhitePoint( void) Parameters: This function does not accept any parameter. Return Value: This function returns the chromaticity white point as an associative array with the ke
1 min read
PHP | Imagick getCompressionQuality() Function
The Imagick::getCompressionQuality() function is an inbuilt function in PHP which is used to get the object compression quality. Syntax: int Imagick::getCompressionQuality( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an integer value on success. Below programs illustrate the Imagick::getCompr
1 min read
PHP | Imagick clear() Function
The Imagick::clear() function is an inbuilt function in PHP which is used to clear all resource allocated to an Imagick object. Syntax: bool Imagick::clear( void ) Parameters: This function does not accept any parameter. It just clears off the resources of the Imagick object which is used to call the function. Return Value: This function returns tr
2 min read
PHP | Imagick annotateImage() Function
The Imagick::annotateImage() function is an inbuilt function in PHP which is used to annotates an image with text. This function returns True on success. Syntax: bool Imagick::annotateImage( $draw_settings, $x, $y, $angle, $text ) Parameters: This function accepts five parameters as mentioned above and described below: $draw_settings: This paramete
2 min read
PHP | Imagick adaptiveResizeImage() Function
The Imagick::adaptiveResizeImage() function is an inbuilt function in PHP which provides an adaptively resize image feature to the image. The intensity of an adaptive resize image depends on dramatically decreased at the edge of the image. This function is used to resize the image according to web sites. It is useful when it shrinks the images slig
1 min read
PHP | Imagick adaptiveBlurImage() Function
The Imagick::adaptiveBlurImage() function is an inbuilt function in PHP which is used to add adaptive blur filter in the given image. The intensity of an adaptive blur depends is dramatically decreased at the edge of the image, whereas a standard blur is a uniform across the image. This effect makes the image unclear or less distinct. Syntax: bool
2 min read