I've tried using the following code but it produces weird results:
Code: Select all
$image //foreground image resource
$background //background image resource
sscanf($colortobetransparent,"%2x%2x%2x", $red, $green, $blue);
$pbColour=ImageColorAllocate($background,$red,$green,$blue);
$transparentindex = imagecolortransparent($background, $pbColour);
imagecopymerge($image, $background $backx, $backy, 0,0,$backwidth, $backheight, 100);
imagejpeg($image);
imagedestroy($background);