A small script that uses php to make text based images. EX:
http://www.domain.com/test/index.php?text=MY_TEXT
would show up with a png or jpg saying "MY_TEXT".
A small script that uses php to make text based images. EX:
http://www.domain.com/test/index.php?text=MY_TEXT
would show up with a png or jpg saying "MY_TEXT".
Take a look at this:
http://us2.php.net/manual/en/function.imagecreate.php
Hope this helps.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
Thank you!!! I edited the file a bit to work out just in case u wanted to know.
index.php?text=texthereCode:<?php header("Content-type: image/png"); $im = @imagecreate(110, 20) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 0, 0, 0); $text_color = imagecolorallocate($im, 233, 14, 91); $text = $_GET["text"]; imagestring($im, 1, 5, 5, $text, $text_color); imagepng($im); imagedestroy($im); ?>
actually, one more thing. If my the text is longer than the image it doesnt expand the image it just kinda runs off the edge. How ould I fix this?
EDIT>Code:<?php header("Content-type: image/png"); $im = @imagecreate(100, 15) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 142, 72, 151); $text_color = imagecolorallocate($im, 0, 0, 0); $text = $_GET["text"]; imagestring($im, 3, 1, 1, $text, $text_color); imagepng($im); imagedestroy($im); ?>
Just like always i figured it out. heres my solution.
I seen that each character takes up 7 pixels including a space. So it takes the string from the url and multiplies it by 7. haha!<?php
header("Content-type: image/png");
//Ben's Inserts
$text = $_GET["text"];
$str = strlen($text);
$str2 = 7;
$total = $str * $str2;
//End Bens inserts
$im = @imagecreate($total, 15)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 142, 72, 151);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 3, 0, 0, $text, $text_color);
imagepng($im);
imagedestroy($im);
?>
Last edited by benslayton; 05-19-2007 at 05:56 AM. Reason: problemo solved!!!
Bookmarks