note 83316 added to function.imagettftext
| From: | Stefan at colulus dot com | Date: | Tue, 20 May 2008 17:40:52 +0000 |
| Subject: | note 83316 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139560@lists.php.net to get a copy of this message | ||
I worked out a script the allows the transfer of alphanumeric data to be placed on an image. The
HTML feature is img src and the php feature is imagettftext. This simple code will increment from 1
to 3 on images.
code:
<?php
//ImageCall.php -- This script will call a script to produce the image.
for($next = 1;$next < 4; $next++){
print "Image $next:<br>";
print "<img src = 'Image.php?\$text=$next'>";
print "<br><br>";
}
?>
<?php
//Image.php -- This script creates a square image and places the text on it.
// image size and color
$im = ImageCreate(77,77);
$color1 = ImageColorAllocate($im,0x66,0xCC,0x00);
$color2 = ImageColorAllocate($im,0x33,0x66,0x00);
$color3 = ImageColorAllocate($im,0x00,0x99,0x00);
$color4 = ImageColorAllocate($im,0x3D,0x3D,0x3D);
// image creation
ImageFilledRectangle($im,1,1,76,76,$color1);
ImageFilledpolygon($im, array (76,1,1,76,76,76),3,$color2);
ImageFilledRectangle($im,5,5,72,72,$color3);
// determine numeric center of image
$size = ImageTTFBBox(45,0,'impact',$_GET['$text']);
$X = (77 - (abs($size[2]- $size[0])))/2;
$Y = ((77 - (abs($size[5] - $size[3])))/2 + (abs($size[5] - $size[3])));
//places numeric information on image
ImageTTFText($im,45,0,($X-1),$Y,$color4,'impact',$_GET['$text']);
//returns completed image to calling script
Header('Content-Type: image/png');
Imagepng($im);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 71.214.140.1
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit -- https://master.php.net/note/edit/83316
Del: integrated -- https://master.php.net/note/delete/83316/integrated
Del: useless -- https://master.php.net/note/delete/83316/useless
Del: bad code -- https://master.php.net/note/delete/83316/bad+code
Del: spam -- https://master.php.net/note/delete/83316/spam
Del: non-english -- https://master.php.net/note/delete/83316/non-english
Del: in docs -- https://master.php.net/note/delete/83316/in+docs
Del: other reasons-- https://master.php.net/note/delete/83316
Reject -- https://master.php.net/note/reject/83316
Search -- https://master.php.net/manage/user-notes.php