Kamis, 14 Mei 2009

Generate Image from E-mail Text with PHP

I wonder how to generate a image from email text with PHP. Sometimes people need imaging their e-mail addres in a webpage to ensure that their e-mail address doesn't detected by bad bots or robots that can sends thousand of spams or unwanted e-mail.

One of the effective way is making a image as our e-mail address. But how we can make that..?
Here is the simple source code to generate a image from string input with PHP.



<?php
header("Content-type: image/png");
// Your email address which will be shown in the image
$email = "you@yourdomain.com";
$length = (strlen($email)*8);
$im = @ImageCreate ($length, 20)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 255, 255, 255);
// White: 255,255,255
$text_color = ImageColorAllocate ($im, 55, 103, 122);
imagestring($im, 3,5,2,$email, $text_color);
imagepng ($im);
?>



the principal code above are
  • @ImageCreate
  • imagestring and
  • imagepng.
Related Post:

Tidak ada komentar: