note 101128 deleted from function.imagettftext by cmb
| From: | cmb@php.net | Date: | Tue, 13 Sep 2016 17:15:40 +0000 |
| Subject: | note 101128 deleted from function.imagettftext by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206574@lists.php.net to get a copy of this message | ||
Note Submitter: contact at pointhunter dot net
----
Print username on the picture from a sent variable. (u)
<?php
$USERNAME=$_REQUEST['u'];
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor(350, 30);
// Create some colors
$white = imagecolorallocate($im, 0, 0, 0);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Welcome, '.$USERNAME;
// Replace path by your own font path
$font = 'cour.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>