note 17170 added to function.imagegif
| From: | me at carrie dot cc | Date: | Wed, 28 Nov 2001 16:46:45 +0000 |
| Subject: | note 17170 added to function.imagegif | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21383@lists.php.net to get a copy of this message | ||
I am trying to create a gif image on the fly using text and a specific font. Is there anyway to
dynamically resize the image to the size of the text paragraph? This is my code:
<?php
header("Content-type: image/gif");
$width = 400;
$height = 400;
$image = imagecreate($width, $height);
$white = imagecolorallocate($image,255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $width, $height, $black);
$text = wordwrap($text, 40, "\n\r");
imagettftext($image, 24, 0, 0, 50, $white, "verdana.ttf", "$text");
//Push the completed image out.
imagecolortransparent($image, $black);
imagegif($image);
imagedestroy($image);
?>
as you can see, it creates a rectangle initially for the image, and then put the font into the
rectangle. somehow, i need to make that rectangle dynamically resize to fit the text, otherwise, the
words get cropped off, or i have an enormous image for two words. any ideas?
thanks!
carrie
me@carrie.cc
--
http://www.php.net/manual/en/function.imagegif.php
http://master.php.net/manage/user-notes.php?action=edit+17170
http://master.php.net/manage/user-notes.php?action=delete+17170
http://master.php.net/manage/user-notes.php?action=reject+17170