note 83316 deleted from function.imagettftext by cmb

From: Date: Tue, 13 Sep 2016 17:13:27 +0000
Subject: note 83316 deleted from function.imagettftext by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206571@lists.php.net to get a copy of this message
Note Submitter: Stefan at colulus dot com ---- 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); ?>

« previous php.notes (#206571) next »