HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue

Append images

← annotateImage   averageImages →
Append a set of images into one larger image.
This function only works if the internal iterator in the image is reset to 0 before the function is called.


function appendImages()
    $images = [
    $canvas = new Imagick();

    foreach ($images as $imageRow) {
        $rowImagick = new Imagick();
        foreach ($imageRow as $image_path) {
            $imagick = new Imagick(realpath($image_path));
            $imagick->resizeimage(200, 200, \Imagick::FILTER_LANCZOS, 1.0, true);
        //Add the images horizontally.
        $combinedRow = $rowImagick->appendImages(false);

    //Add the images vertically.
    $finalimage = $canvas->appendImages(true);

    header("Content-Type: image/jpeg");
    echo $finalimage->getImageBlob();