Original background:
Original foreground:
Another original foreground:
Blended image:
<?php
header('Content-type: image/jpeg');

$im = imagecreatetruecolor(320, 240);
$np = imagecreatetruecolor(160, 120);
$np2 = imagecreatetruecolor(160, 120);
$img1 = imagecreatefromjpeg('bg/test001.jpg');
$img2 = imagecreatefrompng('bg/test002.png');
$img3 = imagecreatefrompng('bg/test003.png');

imagealphablending($np, false);
imagecopyresampled($np, $img2, 0, 0, 0, 0, 160, 120, 320, 240);
imagealphablending($np2, false);
imagecopyresampled($np2, $img3, 0, 0, 0, 0, 160, 120, 320, 240);

imagecopy($im, $img1, 0, 0, 0, 0, 320, 240);
imagecopy($im, $np, -40, -40, 0, 0, 160, 120);
imagecopy($im, $np2, -20, -20, 0, 0, 160, 120);
imagecopy($im, $np, 0, 0, 0, 0, 160, 120);
imagecopy($im, $np2, 20, 20, 0, 0, 160, 120);
imagecopy($im, $np, 40, 40, 0, 0, 160, 120);
imagecopy($im, $np2, 60, 60, 0, 0, 160, 120);
imagecopy($im, $np, 80, 80, 0, 0, 160, 120);
imagecopy($im, $np2, 100, 100, 0, 0, 160, 120);
imagecopy($im, $np, 120, 120, 0, 0, 160, 120);
imagecopy($im, $np2, 140, 140, 0, 0, 160, 120);
imagecopy($im, $np, 160, 160, 0, 0, 160, 120);

$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
imagettftext($im, 36, 0, 45, 140, $black, 'fonts/arial.ttf', 'Here I am.');
imagefttext($im, 36, 0, 44, 139, $white, 'fonts/arial.ttf', 'Here I am.');

imagejpeg($im);

imagedestroy($img1);
imagedestroy($img2);
imagedestroy($img3);
imagedestroy($im);
imagedestroy($np);
imagedestroy($np2);
?>