View unanswered posts | View active topics It is currently Sat Aug 13, 2022 8:40 pm



Reply to topic  [ 2 posts ] 
 Image Color Transparent 
Author Message
Junior Member

Joined: Mon May 24, 2004 8:54 am
Posts: 2
Post 
Hi I am using following code to make the a color transparent in an image.

Code:
<?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.

_________________
it's not nessacery taht each word sholud be corrcet to read the whloe staetment :)


Mon May 24, 2004 9:05 pm
Report this post
Profile
Junior Member

Joined: Sat May 10, 2003 1:39 pm
Posts: 37
Post 
Your code looks ok. I ran it (substituting text string) then if I used

<img src='test.png'>

in an html file, I get a transparent background.

Also, if I took out the filename from imagepng() and used (saving your script as testpng.php )

<img src='testpng.php'>

it worked ok.

_________________
Barand


Tue May 25, 2004 2:41 am
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.