I have a custom bicycle configurator that layers transparent png files with css. http://www.gallantbicycles.com/build/no1/
I need to add the ability to combine them into one file dynamically so the user can download an image or share it.
This is where I'm at right now, but it results in a black background and only the front most image is seen in the result:
$width = 720;
$height = 500;
$layers = array();
$layers[] = imagecreatefrompng("pathtomyimage/image.png");
$layers[] = imagecreatefrompng("pathtomyimage/image.png");
$layers[] = imagecreatefrompng("pathtomyimage/image.png");
$image = imagecreatetruecolor($width, $height);
imagealphablending($image, false);
imagesavealpha($image, true);
for ($i = 0; $i < count($layers); $i++) {
imagecopymerge($image, $layers[$i], 0, 0, 0, 0, $width, $height, 100);
}
header('Content-type: image/png');
imagepng($image);