Page 1 of 1

image color transparent

Posted: Mon May 24, 2004 9:46 am
by kevin_javia
Hi I am using following code to make the a color transparent in an image.

Code: Select all

<?php

header ("Content-type: image/png");
$im = imagecreate(500, 400);

$bgc = imagecolorallocate($im, 0, 0, 0);        
$tc = imagecolorallocate($im, 255, 255, 255);     

imagettftext($im, 20, 10, 100, 200, $tc, "/arial.ttf",$text);
imagecolortransparent($im, $bgc);
imagepng($im,"images/test.png");
imagedestroy($im); 

?>
What I am getting is an image with black background with white text. I want to remove the black background.

Can any body help me with this?

Tanks a ton in advance.
Kevin.

Posted: Mon May 24, 2004 9:51 am
by feyd
are you using IE to view it? IE has non-standard support for transparency in PNG files.

Posted: Mon May 24, 2004 9:59 am
by kevin_javia
I even tried the JPEG functions but the results were similar. :(

Posted: Mon May 24, 2004 10:10 am
by feyd
since JPEG doesn't support transparency at all, I wouldn't think it'd make a difference.

Posted: Mon May 24, 2004 11:41 am
by vigge89
save the outputted image, and then open it up in an image previewing program. if it's transparent where it should be, then it's IEs lacking of support which's the problem

Posted: Mon May 24, 2004 10:04 pm
by kevin_javia
I did view the outputed image in ACDC and other programs. There is no transparent portion in the whole image.

That means this is not IEs problem I guess. Can any body throw some light on this topic?

Thanks vigge n feyd.

Kevin.

Posted: Mon May 24, 2004 10:37 pm
by feyd
the only "quick" way to tell if it really has transparency or not, is not through most image viewing programs.. but through a browser known to support it correctly and simply. Create an html with a repeating black and white square background, and place the image into the body. If it continues to not work, then yes, there is a problem.