Page 1 of 1

show png transparent

Posted: Sun Jul 06, 2003 6:36 am
by apfelsaft
hi i have a problem
i have a source picture and i write text on it and then i will show this new picture with a transparent background (backgroundcolor=black)
but it wont work
here is my code

Code: Select all

<?PHP 
Header("Content-type: image/png");
$width = 40; 
$height = 40; 
$color = '000000';
$font = 'FF0000';

function ImageHexColorAllocate(&$image,$hexstr) &#123; 
  return ImageColorAllocate($image,hexdec($hexstr&#1111;0].$hexstr&#1111;1]),hexdec($hexstr&#1111;2].$hexstr&#1111;3]),hexdec($hexstr&#1111;4].$hexstr&#1111;5])); 
&#125; 

$image = ImageCreate($width,$height); 
$org   = ImageCreateFromPNG( "picture.png" );
ImageCopy($image,$org,0,0,0,0,40,40);
ImageString($image,2,7,14,'text',ImageHexColorAllocate($image,$font ));
$trans = ImageColorTransparent($image,ImageHexColorAllocate($image,$color)); 
ImagePNG($image);
imagedestroy($image);
imagedestroy($org);
?>
but my background is still black instead of transparent
does anyone know why ?

please help

Posted: Sun Jul 06, 2003 3:28 pm
by Jean-Yves
What browser are you using? IE seems to have difficulties with some transparent PNG's, though not all for some strange reason. Moz appears ok.

Not sure if that helps...

Posted: Sun Jul 06, 2003 3:30 pm
by m3rajk
like he said, if you're using ie, don't call it a problem till you've tested it elsewhere. ie doesn't have full png support. microsoft doesn't like open source technologies

Posted: Mon Jul 07, 2003 4:31 am
by apfelsaft
i got it now
i changed the script so that it creates a transparent image and copys a transparent source image on it
and i found out that it works with php 4.3.2 (gd libary 2.x) but not with php 4.2.3 (& older gd libary) which my websapceprovider uses

Posted: Tue Jul 08, 2003 10:36 pm
by macewan