Keeping background transparency when converting to GIF

From: Date: Mon, 26 Jan 2009 02:45:48 +0000
Subject: Keeping background transparency when converting to GIF
Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-538@lists.php.net to get a copy of this message
Hello, I'm having a tough time keeping transparency intact when using imagegif() on a transparent image. The image is definitely transparent, as evidenced when using the PNG format .. but once I imagegif() it, the background takes on my transparent color, minus the transparency. Is there something different I could do to make this work as desired? Thanks! -Jason Young Brief example: <?php $font = 'verdana.ttf'; $im = imagecreatetruecolor(100, 50); imagesavealpha($im, true); $trans = imagecolorallocatealpha($im, 20, 50, 50, 127); // To demonstrate non-transparent color $black = imagecolorallocate($im, 0, 0, 0); imagefill($im, 0, 0, $trans); imagettftext($im, 10, 0, 20, 20, $black, $font, 'A transparent background?'); //header('Content-Type: image/png'); // imagepng($im); // This works as expected. header('Content-Type: image/gif'); imagegif($im); // This does not. imagedestroy($im); ?>

« previous php.gd.devel (#538) next »