Connecting Tech Pros Worldwide Help | Site Map

Need transparent background while generating headings at run time

Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#1: Mar 31 '09
Hey,
i have found a code which generate headings at run time. here is my code which generate headings at run time

Expand|Select|Wrap|Line Numbers
  1. <img src="generate-headings.php?w=125&amp;hd=Code" />

Quote:
generate-headings.php Page
Expand|Select|Wrap|Line Numbers
  1. $im = imagecreatetruecolor($_GET[w], 18);
  2. $white = imagecolorallocate($im, 255, 255, 255);
  3. $black = imagecolorallocate($im, 0, 0, 0);
  4. imagefilledrectangle($im, 0, 0,$_GET[w], 18, $white);
  5. $text = $_GET[hd];
  6. $font = "fonts/myriad.ttf";
  7. imagettftext($im,14,0,0,13,$black,$font,$text);
  8. imagepng($im);
  9. imagedestroy($im);

It creates images at run time successfully. But it did not allow me to create headings with transparent background. Is there any way to fixed that issue. Kindly help me out to sort this my problem. I always get a very excellent response from PHP Masters who do a lot for me here in this community so hope to fix this problem too.


Awaiting of reply

kind regards,
Mohsin Rafique
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 913
#2: Mar 31 '09

re: Need transparent background while generating headings at run time


I haven't much experience with creating transparent backgrounds, but have you played around with the:
Expand|Select|Wrap|Line Numbers
  1. imagefilledrectangle($im, 0, 0,$_GET[w], 18, $white);
I imagine that that is where is it making the background?
Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#3: Apr 1 '09

re: Need transparent background while generating headings at run time


Yeh but without that it did not create heading and i want to create heading without background image color etc. I need to create transparent heading
Reply