Page 1 of 1

copying transparent image using GD

Posted: Fri Jul 13, 2007 2:15 pm
by anti_dentite
I'm pretty new to the GD library and am having trouble writing a script that will copy one image (foreground) onto another (background) while allowing some areas of the foreground image to be transparent.

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);
basically it displays a semi-transparent image but it looks really, really bad. What am I missing?