$source = file_get_contents('test.jpg');
$image = imagecreatefromstring($source);
imagesavealpha($image, true);
imagealphablending($image, false);
$width = imagesx($image);
$height = imagesy($image);
$pieces = 7;
$gap = 10;
$piece_width = (int) ($width / $pieces);
$newimage = imagecreatetruecolor(($width + ($pieces - 1) * $gap), $height);
$transparent = imagecolorallocatealpha($newimage, 255, 255, 255, 127);
imagefill($newimage, 0, 0, $transparent);
imagealphablending($newimage, true);
imagesavealpha($newimage, true);
for ($i = 1,
imagecopymerge($newimage, $image, 0, 0, 0, 0, $piece_width, $height, 100);
$i < $pieces;
$i++) {
imagecopymerge($newimage, $image, $gap * $i + $piece_width * $i, 0, $piece_width * $i, 0, $piece_width, $height, 100);
}
header("Content-Type: image/png");
imagepng($newimage, null, 9, PNG_ALL_FILTERS);