Jump to content
MakeWebGames

How to make an email image


Floydian

Recommended Posts

It's nice to have an image to display an image address instead of putting it on the page as text.

This script will create an image with your email addy in it. There isn't really much to explain except for the usage of this, but first, the script:

 

<?php

function getMyEmail($site) {
$emails = array(
	[email="'[email protected]"]'[email protected][/email]',
	[email="'[email protected]"]'[email protected][/email]',
	[email="'[email protected]"]'[email protected][/email]',
);

if (!isset($emails[$site])) {
	return $emails[0];
} else {
	return $emails[$site];
}
}


header("Content-type: image/png");
$im = @imagecreate(200, 30)
   or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 200, 200, 200);
$text_color = imagecolorallocate($im, 23, 36, 90);
imagestring($im, 4, 5, 5,  getMyEmail($_GET['e']), $text_color);
imagepng($im);
imagedestroy($im);

 

Save this script as something like email.php. Then make an img tag like so:

 

email.php?e=0

 

To change the background color, edit this line:

$background_color = imagecolorallocate($im, 200, 200, 200); // That's an RGB of 200,200,200

To change the text color:

$text_color = imagecolorallocate($im, 23, 36, 90); // RGB of 23,36,90

To change the image size:

$im = @imagecreate(200, 30) // width, height

To change the font

imagestring($im, 4, 5, 5, getMyEmail($_GET['e']), $text_color); // That 4 can be anything from 1 to 5, or higher

// (but can only go higher if you loaded your own fonts, which is beyond the scope of this post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...