Creates a composite image by combining several separate images. The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile.
Montage type
Creates a composite image by combining several separate images. The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile.
Parameters
drawImagickDrawThe font name, size, and color are obtained from this object.
tile_geometrystringThe number of tiles per row and page (e.g. 6x4+0+0).
thumbnail_geometrystringPreferred image size and border size of each thumbnail (e.g. 120x120+4+3>).
modeintThumbnail framing mode, see Montage Mode constants.
framestringSurround the image with an ornamental border (e.g. 15x15+3+3). The frame color is that of the thumbnail's matte color.
function montageImage($montageType)
{
    $draw = new \ImagickDraw();
    $draw->setStrokeColor('black');
    $draw->setFillColor('white');
 
    $draw->setStrokeWidth(1);
    $draw->setFontSize(24);

    $imagick = new \Imagick();

    $mosaicWidth = 500;
    $mosaicHeight = 500;
    
    $imagick->newimage($mosaicWidth, $mosaicHeight, 'red');

    $images = [
        "../imagick/images/Biter_500.jpg",
        "../imagick/images/SydneyPeople_400.jpg",
        "../imagick/images/Skyline_400.jpg",
    ];

    $count = 0;
    
    foreach ($images as $image) {
        $nextImage = new \Imagick(realpath($image));
        
        $count++;
        
        $nextImage->labelImage("Label $count");
        $imagick->addImage($nextImage);
    }

    $montage = $imagick->montageImage(
        $draw,
        "3x2+0+0", //tile_geometry
        "200x160+3+3>", //thumbnail_geometry
        $montageType, //\Imagick::MONTAGEMODE_CONCATENATE,
        "10x10+2+2"
    );
    
    $montage->setImageFormat('png');
    
    header("Content-Type: image/png");
    echo $montage->getImageBlob();
}