Flatten multiple transparent PNGs with PHP GD
问题 I am building a product configuration module which requires that multiple transparent PNGs of the same size (which represent product parts) be flattened onto one image. At first I tried this which made the composition of the 3 images but on a black background: <?php $x = 500; $y = 500; $final_img = imagecreatetruecolor($x, $y); $images = array('1.png', '2.png', '3.png'); foreach ($images as $image) { $image_layer = imagecreatefrompng($image); imagecopy($final_img, $image_layer, 0, 0, 0, 0, $x