note 17170 rejected from function.imagegif by jimw

From: Date: Mon, 17 Dec 2001 23:26:41 +0000
Subject: note 17170 rejected from function.imagegif by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23085@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

« previous php.notes (#23085) next »