note 83537 added to function.imagejpeg
| From: | stefan at colulus dot com | Date: | Fri, 30 May 2008 18:16:35 +0000 |
| Subject: | note 83537 added to function.imagejpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140009@lists.php.net to get a copy of this message | ||
I worked out a script that 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');
Imagejpeg($im);
?>
----
Server IP: 208.69.120.35
Probable Submitter: 56.0.143.24
----
Manual Page -- http://www.php.net/manual/en/function.imagejpeg.php
Edit -- https://master.php.net/note/edit/83537
Del: integrated -- https://master.php.net/note/delete/83537/integrated
Del: useless -- https://master.php.net/note/delete/83537/useless
Del: bad code -- https://master.php.net/note/delete/83537/bad+code
Del: spam -- https://master.php.net/note/delete/83537/spam
Del: non-english -- https://master.php.net/note/delete/83537/non-english
Del: in docs -- https://master.php.net/note/delete/83537/in+docs
Del: other reasons-- https://master.php.net/note/delete/83537
Reject -- https://master.php.net/note/reject/83537
Search -- https://master.php.net/manage/user-notes.php