This will merge multiple images into one horizontal image. No attempt is made to blur or intelligently align them. Also note that if you are building up a large image, the total memory in bytes just for the resulting image needed by PHP while processing the script will be equal to 4 image_height image_width in pixels.
<?php
$images = array('image1.jpg', 'image2.jpg', 'image3.jpg');
$data = array();
$totalWidth = 0;
$maxHeight = 0;
foreach($images as $img) {
$attr = getimagesize($img);
$totalWidth += $attr[0];
$maxHeight = max($maxHeight, $attr[1]);
$data[] = array(
'file' => $img,
'attr' => $attr
);
}
$panorama = imagecreatetruecolor($totalWidth, $maxHeight);
$counter = 0;
foreach($data as $img) {
$frame = imagecreatefromstring(file_get_contents($img['file']));
imagecopy(
$panorama,
$frame,
$counter,
0,
0,
0,
$img['attr'][0],
$img['attr'][1]
);
$counter += $img['attr'][0];
imagedestroy($frame);
}
header('Content-Type: image/jpeg');
imagejpeg($panorama, null, 85);