Re: ImageColorTransparent Problem

From: Date: Mon, 09 Aug 2004 04:42:06 +0000
Subject: Re: ImageColorTransparent Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193168@lists.php.net to get a copy of this message
Have you tried it in other browsers? IE 6 / windows PNG support leaves much to be desired, even more so when we want them to be transparent. Try it in Firefox, or some other similar browser. Same results? Matthew Runo http://www.quabbo.com Quabbo Internet Services The only host with the Zend Performance Suite! On Aug 8, 2004, at 9:32 PM, Kevin wrote:
Hi, I am having PHP Version 4.3.4 with GD 2.0.15 compatible and PNG support enabled. My problem with the following code is that the image produced be this code is not transparent. It has a black background. I have viewed it in IE 6 and its not transparent. Can someone help me how to make this image transparent? <?php // imagecolorallocate ( resource image, int red, int green, int blue) // imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text) // imagepng ( resource image [, string filename]) // imagecreatetruecolor ( int x_size, int y_size) // imagecolortransparent ( resource image [, int color]) header("Content-type: image/png"); $im = imagecreatetruecolor(400,600); // i have used imagecreatetruecolor in place of imagecreate() $bg = imagecolorallocate($im, 0, 0, 0); imagecolortransparent($im, $bg); // this function makes the color transparent specified in $bg. $j=0; $k = 0; $r = 1; $g = 100; $b = 20; for($i=1;$i<=50;$i++) {
     if($r > 255)
          $r = 1;
     if($g > 255)
          $g = 100;
     if($b > 255)
          $b = 20;
     $textcolor = imagecolorallocate($im, $r, $g, $b);
     $r = $r * 3;
     $g = $g + 10;
     $b = $b + 20;
     imagettftext($im, 10, 0, 0, $j, $textcolor, "fonts/2.ttf", "Row number
: $i | Color = " . $textcolor);
     $j=$j+12;
} imagepng($im,"kk.png"); ?> Thanks a lot for reading this far. -- Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#193168) next »