note 21489 added to function.imageftbbox
| From: | phpimageftbbox at juggernaut dot com dot au | Date: | Wed, 15 May 2002 01:56:08 +0000 |
| Subject: | note 21489 added to function.imageftbbox | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30652@lists.php.net to get a copy of this message | ||
This function can be used to generate right-aligned text. Just work out how wide the text image is
and position it accordingly. Example:
$i_width = 200;
$i_height = 40;
$string = "Hello World!";
$pointsize = 10;
$fontfile = "/usr/local/lib/ttf/Helve.ttf";
$im = imagecreate($i_width, $i_height);
$black = imagecolorallocate ($im, 0, 0, 0);
$white = imagecolorallocate ($im, 255, 255, 255);
$string_size = ImageFtBbox($pointsize, 0, $fontfile, $string, array("linespacing" =>
1));
$s_width = $string_size[4];
$s_height = $string_size[5];
ImageFtText($im, $pointsize, 0, $i_width - $s_width - 1, 0 - $s_height, $white, $fontfile, $string,
array("linespacing" => 1));
Header ("Content-type: image/png");
ImagePNG ($im);
ImageDestroy ($im);
--
http://www.php.net/manual/en/function.imageftbbox.php
http://master.php.net/manage/user-notes.php?action=edit+21489
http://master.php.net/manage/user-notes.php?action=delete+21489
http://master.php.net/manage/user-notes.php?action=reject+21489