note 71995 added to function.imagestring
| From: | dot) | Date: | Thu, 28 Dec 2006 02:53:42 +0000 |
| Subject: | note 71995 added to function.imagestring | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120975@lists.php.net to get a copy of this message | ||
I like this better than "tjpoe at cableaz dot com"'s function for wrapping text to
fit width (auto-adjusts height as needed) since it doesn't only do 1 word per line.
function make_wrapped_txt($txt, $color=000000, $space=4, $font=4, $w=300) {
if (strlen($color) != 6) $color = 000000;
$int = hexdec($color);
$h = imagefontheight($font);
$fw = imagefontwidth($font);
$txt = explode("\n", wordwrap($txt, ($w / $fw), "\n"));
$lines = count($txt);
$im = imagecreate($w, (($h * $lines) + ($lines * $space)));
$bg = imagecolorallocate($im, 255, 255, 255);
$color = imagecolorallocate($im, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8),
0xFF & $int);
$y = 0;
foreach ($txt as $text) {
$x = (($w - ($fw * strlen($text))) / 2);
imagestring($im, $font, $x, $y, $text, $color);
$y += ($h + $space);
}
header('Content-type: image/jpeg');
die(imagejpeg($im));
}
----
Server IP: 216.194.113.175
Probable Submitter: 24.177.150.118
----
Manual Page -- http://www.php.net/manual/en/function.imagestring.php
Edit -- https://master.php.net/note/edit/71995
Del: integrated -- https://master.php.net/note/delete/71995/integrated
Del: useless -- https://master.php.net/note/delete/71995/useless
Del: bad code -- https://master.php.net/note/delete/71995/bad+code
Del: spam -- https://master.php.net/note/delete/71995/spam
Del: non-english -- https://master.php.net/note/delete/71995/non-english
Del: in docs -- https://master.php.net/note/delete/71995/in+docs
Del: other reasons-- https://master.php.net/note/delete/71995
Reject -- https://master.php.net/note/reject/71995
Search -- https://master.php.net/manage/user-notes.php