note 39329 added to function.imagefttext
| From: | eshenk at comcast dot net | Date: | Sat, 24 Jan 2004 19:05:39 +0000 |
| Subject: | note 39329 added to function.imagefttext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64124@lists.php.net to get a copy of this message | ||
I wrote a bit of code to gather all the .ttf files in the directory with this script, and randomize
them to write text on a header image for my site. The only catch is the font files have to be named
1.ttf, 2.ttf etc etc.
<?php
srand((double)microtime()*1234567); // Start the random gizmo
$image = imagecreatefromjpeg(rand(1,exec('ls *.jpg | wc -l')) . ".jpg"); // Get
a background
$font = rand(1,exec('ls *.ttf | wc -l')) . ".ttf"; // Get a font
$textcolor = imagecolorallocate($image,0,0,0); // Set text color
$text1 = "shenko.homedns.org"; // Here is our text
imagettftext($image, 50, 0, 20, 50, $textcolor, $font, $text1); // Write the text with a font
header("Content-type: image/jpeg"); // Its a JPEG
imagejpeg($image,'',90); // Zap it to the browser
imagedestroy($image); // Memory Freeupage
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagefttext.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39329
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39329&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39329&report=yes
Search -- http://master.php.net/manage/user-notes.php