note 80199 added to function.imagestring
| From: | eviloverlord+php at gmail dot com | Date: | Thu, 03 Jan 2008 23:28:40 +0000 |
| Subject: | note 80199 added to function.imagestring | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-134735@lists.php.net to get a copy of this message | ||
Simple script to convert a string (such as an email addresses) to a transparent image.
Usage:
<img src="stringtoimg.php?string=<?= urlencode(base64_encode($email)) ?>">
From a spambot's point of view, they see:
<img src="stringtoimg.php?string=ZpbXZG92ZXJsb3JkQGdtYWlsLmNvbQ%3D%3D">
Optional parameters:
font_size: 1 to 5, with the default at 3
R/G/B: the font color, in hex.
Usage:
<img src="stringtoimg.php?string=<?= urlencode(base64_encode($email))
?>&font_size=4&R=FF&G=FF&B=00">
<?php
/*
Filename: stringtoimg.php
Parameters:
string: the string to print
font_size (optional): the size of the font from 1-5
R/G/B (optional): the RGB colors of the font in hex
*/
header ("Content-type: image/png");
//Get string info
$font_size = isset($_GET['font_size']) ? $_GET['font_size'] : 3;
$string = urldecode(base64_decode($_GET['string']));
//Get the size of the string
$width = imagefontwidth($font_size) * strlen($string);
$height = imagefontheight($font_size);
//Create the image
$img = @imagecreatetruecolor($width, $height)
or die("Cannot Initialize new GD image stream");
//Make it transparent
imagesavealpha($img, true);
$trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127);
imagefill($img, 0, 0, $trans_colour);
//Get the text color
$text_color = isset($_GET['R'], $_GET['G'], $_GET['B']) ?
imagecolorallocate($img, hexdec($_GET['R']), hexdec($_GET['G']),
hexdec($_GET['B'])) :
imagecolorallocate($img, 0, 0, 0);
//Draw the string
imagestring($img, $font_size, 0, 0, $string, $text_color);
//Output the image
imagepng($img);
imagedestroy($img);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 128.187.80.2 (proxied: 127.0.0.1)
----
Manual Page -- http://www.php.net/manual/en/function.imagestring.php
Edit -- https://master.php.net/note/edit/80199
Del: integrated -- https://master.php.net/note/delete/80199/integrated
Del: useless -- https://master.php.net/note/delete/80199/useless
Del: bad code -- https://master.php.net/note/delete/80199/bad+code
Del: spam -- https://master.php.net/note/delete/80199/spam
Del: non-english -- https://master.php.net/note/delete/80199/non-english
Del: in docs -- https://master.php.net/note/delete/80199/in+docs
Del: other reasons-- https://master.php.net/note/delete/80199
Reject -- https://master.php.net/note/reject/80199
Search -- https://master.php.net/manage/user-notes.php