Php – Combine 2-3 transparent PNG images on top of each other with PHP

gd, image, image-manipulation, php, png

I am working on a custom avatar system for a project, but I have never really done much with the image side of PHP. I assume I need to use GD in some way, but I have no idea where to even start.

Basically, there are a bunch of pre-made transparent PNG images. Users can select 2-3 of them to customize their avatar, and I want to be able to take these images and make a single image out of them to be stored in a folder.

Best Solution

$image_1 = imagecreatefrompng('image_1.png');$image_2 = imagecreatefrompng('image_2.png');imagealphablending($image_1, true);imagesavealpha($image_1, true);imagecopy($image_1, $image_2, 0, 0, 0, 0, 100, 100);imagepng($image_1, 'image_3.png');