note 33084 added to function.imagestring
| From: | php at ukchatterbox dot com | Date: | Mon, 16 Jun 2003 12:38:17 +0000 |
| Subject: | note 33084 added to function.imagestring | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-50418@lists.php.net to get a copy of this message | ||
<?php
/* Creates a Random word image, to prevent automatic signup
If you provide $hash (int) through get or POST it
will use that word in the array $wordlist otherwise it will make a random image.
Automatically creates some background circles which
will be randomised to a lighter colour than the text
$circle is the number of background circles
Hope you find this useful
*/
$wordlist=array("butter","clock","wood","mouse","medel","cup","bread",
"crisps","towel","chair",
"bottle","can", "potatoe","brush","hat",
"carpet","wires","music","humans","dog","cat");
$circles=5;
$width=100;
$height=40;
$font=3;
$randno=rand(0,sizeof($wordlist)-1);
if (!$hash) {
$string=$wordlist[$randno];
} else {
$string=$wordlist[$hash];
}
$fontwidth = ImageFontWidth($font) * strlen($string);
$fontheight = ImageFontHeight($font);
$im = @imagecreate ($width,$height);
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, rand(0,100), rand(0,100),
rand(0,100)); // Random Text
for ($i=1;$i<=$circles;$i++) {
$randomcolor = imagecolorallocate ($im , rand(100,255),
rand(100,255),rand(100,255));
imagefilledellipse($im,rand(0,$width-10),rand(0,$height-3),
rand(20,70),rand(20,70),$randomcolor);
}
imagerectangle($im,0,0,$width-1,$height-1,$text_color);
imagestring ($im, $font, rand(3, $width-$fontwidth-3),
rand(2,$height-$fontheight-3), $string, $text_color);
header ("Content-type: image/jpeg");
imagejpeg ($im,'',80);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagestring.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33084
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33084&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33084&report=yes