Created
January 21, 2013 09:46
-
-
Save Taluu/4584914 to your computer and use it in GitHub Desktop.
Mail to GD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('MAIL_PLUS_WIDTH', 10); | |
define('MAIL_PLUS_HEIGHT', 10); | |
define('MAIL_POS_WIDTH', (MAIL_PLUS_WIDTH / 2) ); | |
define('MAIL_POS_HEIGHT', (MAIL_PLUS_HEIGHT / 2) ); | |
/** | |
* Transform a adresse mail to GD. | |
* @param string $mail mail du membre | |
* @param string $where ou l'enregistrer ? | |
* @return string img addr | |
*/ | |
function mail2gd($mail, $where = '.'){ | |
$where .= DIRECTORY_SEPARATOR . sha1($mail) . '.png'; | |
if( !file_exists($where) ){ | |
$img = imagecreate(strlen($mail)*7 + MAIL_PLUS_WIDTH, 15 + MAIL_PLUS_HEIGHT); | |
$bg = imagecolorallocate($img, 255, 255, 255); | |
$txt = imagecolorallocate($img, 0, 0, 0); | |
imagestring($img, 3, MAIL_POS_WIDTH, MAIL_POS_HEIGHT, $mail, $txt); | |
imagepng($img, $where); | |
} | |
return $where; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment