GD generated email address

This example came about with the need to display an email address on a site but reducing the risk that some clown would use an email harvester to obtain this from your website, it uses php and the GD library to generate an image which contains your email address

<?php
Header(“Content-type: image/jpeg”);
//create a new image
$image = ImageCreate(200,200);
//create white (for background )
$white = ImageColorAllocate($image ,255,255,255);
//create blue for text
$blue = ImageColorAllocate($image , 0,0,255);
//OK lets create our white background
ImageFilledRectangle($image ,0,0,200,200,$white);
//display some text
ImageString($image,10,15,10,’youremail@youremail.com’,$blue);
//output image to browser as a JPEG
ImageJPEG($image);
//clean up by destroying the image
ImageDestroy($image);
?>

NOw include this on your page like this

<img src=”gdemail.php”>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*