I would like to merge multiple pngs with transparent background into one image. Images have different sizes and because of this, when images are placed over the top of each other, only within the size of the uppermost image are shown the parts of the merged images.
It's like the last image applies like a mask for the images merged before. I would like to see all the images merged with their original size, without cropping the parts hanging over the size of the last image.
Here is the code I'm using currently:
$images = array();
foreach (scandir($this->img_dir) as $key => $dirname) {
if(!strstr($dirname, "."))
{
if(isset($_GET[$dirname]))
{
foreach ($this->layer_order as $lkey => $order) {
if($lkey == $dirname)
$images[$order] = glob($this->img_dir . "/" . $dirname . "/" . $_GET[$dirname] . ".png");
}
}
}
}
$destination = imagecreatetruecolor(458, 600);
imagealphablending($destination, true);
imagesavealpha($destination, true);
ksort($images);
foreach($images as $key => $value) {
foreach ($value as $fn) {
// Load image
$source = imagecreatefrompng($fn);
//$source = $this->resize_image($source, 50, 50, 2);
// Copy over image
imagecopy($destination, $source, 10, 50, 0, 0, 458, 600);
// Free memory
imagedestroy($source);
}
}
return $destination;