PHP script to write email address into a image
I was after a php script that dynamically converts text to image and finally i decided to code on my own. It also does convert small length text to image like names, emails etc..
This script automatically calculates the width of text into pixels inserts the PNG or gif image.
To call the script for dynamically generating an image just use the html code
and the code for the script is
Requirements:
Apache
PHP GD Library with PNG/GIF/JPEG support
I was after a php script that dynamically converts text to image and finally i decided to code on my own. It also does convert small length text to image like names, emails etc..
This script automatically calculates the width of text into pixels inserts the PNG or gif image.
Code:
this is a string to < >
Code:
<img src="txt2img.php?text=<? echo $str ?>" border="0">
Code:
//source for txt2img.php <? if(!isset($_GET['txt'])) { exit(); } header ("Content-type: image/png"); $string = $_GET['txt']; $font = 4; $width = ImageFontWidth($font) * strlen($string); $height = ImageFontHeight($font); $im = @imagecreate ($width,$height); $background_color = imagecolorallocate ($im, 255, 255, 255); //white background $text_color = imagecolorallocate ($im, 0, 0,0);//black text imagestring ($im, $font, 0, 0, $string, $text_color); imagepng ($im); ?>
Requirements:
Apache
PHP GD Library with PNG/GIF/JPEG support
Comment