List Info

Thread: note 62436 added to ref.image




note 62436 added to ref.image
user name
2006-02-28 17:47:55
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.p
hp.net/note/edit/62436
Del: integrated  -- ht
tp://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://m
aster.php.net/note/delete/62436/spam
Del: non-english -- h
ttp://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://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )