Hey, If anyone can help me with this at all, I would really appreciate it...
| From: | Ryan Smaglik | Date: | Sat, 14 Dec 2002 22:31:54 +0000 |
| Subject: | Hey, If anyone can help me with this at all, I would really appreciate it... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128301@lists.php.net to get a copy of this message | ||
I got a generic ³text to png on the fly² script which works fine but I want
to change it so that the image only the size of the text. (so the text has
no border, or padding around it) For and example of what I want to do check
out: http://www.spoono.com/font/?string=This
is what i want to do&.png
I have the script:
<?
Header("Content-type: image/png");
if(!isset($s)){$s=8;}
$size =
imagettfbbox($s,0,"/home/xelerix/public_html/font/fonts/04B_03__.TTF",$text)
;
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
$xpad=9;
$ypad=9;
$im = imagecreate($dx+$xpad,$dy+$ypad);
$bg = ImageColorAllocate($im, 102,102,102);
$white = ImageColorAllocate($im, 255,255,255);
ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2), $white,
"/home/xelerix/public_html/font/fonts/04B_03__.TTF", $text);
imagepng($im);
ImageDestroy($im);
?>
The text for the image is called from a url like
www.xelerix.com/font/font.php?text=Hi
Thanks!