How to Display Your Email Address As Image?


The search engines are crawling the web every second. Some are good but some mis-use the information e.g. your email addresses and sell them to third party. You then will receive lots of spam emails.

For example, in you home pages, you probably are nice to leave your email address for others to contact. The email address is shown as simply text. In order to avoid being treated as emails by spiders, you can re-write the ‘@’ symbol by ‘AT’, ‘[AT]’ or something similar. This isn’t good enough.

Now, you can simply replace your text in your HTML by <img> which should be linked to e.g. https://steakovercooked.com/app/email/?e=hello&d=example.com (replace the name and the domain)

The above will generate an image:

?e=hello&d=example How to Display Your Email Address As Image? php technical tools / utilities

Isn’t it easy and convenient ?

The PHP script is very straightforward, parsing two GET-parameters from Query String and print the email string using the GD library.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  // https://helloacm.com/leave-your-email-address-with-image/
  $id = "user";
  if (isset($_GET['e']))
  {
    $id = trim($_GET['e']);
  }  
  $dd = "domain";
  if (isset($_GET['d']))
  {
    $dd = trim($_GET['d']);
  }  
  $id = $id."@".$dd;
  header("Content-type: image/PNG"); 
  $font=5;
  if (isset($_GET["f"]))
  {
    $font=$_GET["f"];
  }    
  $width=(strlen($id) + 1) * imagefontwidth($font);
  $height=imagefontheight($font) + 5;
  if (isset($_GET["w"]))
  {
    $width=(integer)$_GET["w"];
  }
  if (isset($_GET["h"]))
  {
    $height=(integer)$_GET["h"];
  }
  $im = @imagecreate($width,$height); 
  $white = ImageColorAllocate($im, 255,255,255);
  $textcolor = ImageColorAllocate($im, 0,0,0); 
  imagestring($im, $font, 7, 3, $id, $textcolor); 
  ImagePNG($im); 
  ImageDestroy($im); 
  // https://helloacm.com/leave-your-email-address-with-image/
  $id = "user";
  if (isset($_GET['e']))
  {
    $id = trim($_GET['e']);
  }  
  $dd = "domain";
  if (isset($_GET['d']))
  {
    $dd = trim($_GET['d']);
  }  
  $id = $id."@".$dd;
  header("Content-type: image/PNG"); 
  $font=5;
  if (isset($_GET["f"]))
  {
    $font=$_GET["f"];
  }    
  $width=(strlen($id) + 1) * imagefontwidth($font);
  $height=imagefontheight($font) + 5;
  if (isset($_GET["w"]))
  {
    $width=(integer)$_GET["w"];
  }
  if (isset($_GET["h"]))
  {
    $height=(integer)$_GET["h"];
  }
  $im = @imagecreate($width,$height); 
  $white = ImageColorAllocate($im, 255,255,255);
  $textcolor = ImageColorAllocate($im, 0,0,0); 
  imagestring($im, $font, 7, 3, $id, $textcolor); 
  ImagePNG($im); 
  ImageDestroy($im); 

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
330 words
Last Post: Iterative Computing Fib Number using Excel
Next Post: Codeforces: A. Winner

The Permanent URL is: How to Display Your Email Address As Image?

Leave a Reply