我有一个自定义的自行车配置器,它使用 css 对透明的 png 文件进行分层。 http://www.gallantbicycles.com/build/no1/
我需要添加将它们动态组合到一个文件中的功能,以便用户可以下载图像或共享它。
这是我现在所处的位置,但它会导致黑色背景,结果中只看到最前面的图像:
$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);