Example
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 = [
"../public/images/Biter_500.jpg",
"../public/images/SydneyPeople_400.jpg",
"../public/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();
}