note 62436 added to ref.image
| From: | andrew dot barlow at gmail dot com | Date: | Tue, 28 Feb 2006 17:47:55 +0000 |
| Subject: | note 62436 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104568@lists.php.net to get a copy of this message | ||
To create a simple transparent gif with black text with any TrueType Font...
Simple put this script into a PHP file and call it with the usual IMG tag.
You can also specify the font size for the IMG tag too.
Change the $font to your own font and upload it to the same directory as this script.
<?php
// Set the content-type
header("Content-type: image/gif");
$fontsize = 18;
if(@$_GET['fontsize']) {
$fontsize = $_GET['fontsize'];
}
$font = 'yourcustomfont.ttf';
$text = @$_GET['text'];
// Create the image
$size = imagettfbbox($fontsize, 0, $font, $text);
$width = $size[2] + $size[0] + 8;
$height = abs($size[1]) + abs($size[7]);
$im = imagecreate($width, $height);
$colourBlack = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $colourBlack);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// Add the text
imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $text);
// Using imagepng() results in clearer text compared with
imagegif($im);
imagedestroy($im);
?>
----
Server IP: 84.18.202.180
Probable Submitter: 86.140.75.176
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.image.php
Edit -- http://master.php.net/note/edit/62436
Del: integrated -- http://master.php.net/note/delete/62436/integrated
Del: useless -- http://master.php.net/note/delete/62436/useless
Del: bad code -- http://master.php.net/note/delete/62436/bad+code
Del: spam -- http://master.php.net/note/delete/62436/spam
Del: non-english -- http://master.php.net/note/delete/62436/non-english
Del: in docs -- http://master.php.net/note/delete/62436/in+docs
Del: other reasons-- http://master.php.net/note/delete/62436
Reject -- http://master.php.net/note/reject/62436
Search -- http://master.php.net/manage/user-notes.php