note 14695 added to function.imagettfbbox.php
| From: | manu at cappelleri dot net | Date: | Fri, 10 Aug 2001 01:56:37 +0000 |
| Subject: | note 14695 added to function.imagettfbbox.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16527@lists.php.net to get a copy of this message | ||
This example will draw a label of the size of the text...
Works only with 0 as the angle...
<?php
// Draws a graphic label with centered text
// by manu AT cappelleri.net
// Call it as <img src="label.php?label=yourtexthere">
Header ("Content-type: image/png");
//vars
$fontfile = "fonts/labelg.ttf";
$fontsize = 23;
$im_h = 23;
$size = ImageTTFBbox ($fontsize, 0, $fontfile , stripslashes($label));
$im_x = $size[2];
$im = imagecreate ($im_x + 10, $im_h);
$bkgc = ImageColorAllocate ($im, 255, 255, 255);
$txtc = ImageColorAllocate ($im, 197, 196, 230);
ImageTTFText ($im, $fontsize, 0, 5, 20, $txtc, $fontfile, stripslashes($label));
ImagePng ($im);
ImageDestroy ($im);
?>
http://www.php.net/manual/en/function.imagettfbbox.php