I have code like this in a function:
function stacklayer($folder, $layer) {
$newlayer = imagecreatefrompng($folder . '/' . $layer . '.png');
imagecopy($baseimage,$newlayer,0,0,0,0,$w,$h);
imagedestroy($newlayer);
}
stacklayer('Layer1', 'Image1')
But $baseimage does not have the new layers added on top of $baseimage created outside the function.
In this manner:
$baseimage = imagecreatefrompng("Base.png");
$w = imagesx($baseimage); $h = imagesy($baseimage);
imagealphablending($baseimage,true);
If I run this outside the function it adds the layers as intended.
$folder = 'Layer1', $layer = 'Image1';
$newlayer = imagecreatefrompng($folder . '/' . $layer . '.png');
imagecopy($baseimage,$newlayer,0,0,0,0,$w,$h);
imagedestroy($newlayer);
Any help?
Thanks
3dron