PHP Source:

<?php
// CHXO labelgen -- converts a string to a PNG image, mostly to camoflage email addys on websites
// Homepage: http://chxo.com/berylium/software/labelgen.html
//
// 2003-04-14 -- initial version
// 2003-04-15 -- added GPL and showsource, no antialiasing at 10 pixels or less

// TODO:
//  i18n testing and a unicode font
//  image cache subsystem
//  convert to free fonts??? help!

/*
labelgen.php -- text-to-PNG-image converter using PHP
Copyright (C) 2003 by Chris Snyder (csnyder@chxo.com)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

// setup
$fontpath= "/home/chxo/http/labelgen/";
//$fontpath= "/home/csnyder/files/websites/chxo.com/http/labelgen/";
$font= $_REQUEST['font'];
$textval= $_REQUEST['textval'];
$size= $_REQUEST['size'];
$padding= $_REQUEST['padding'];
$bgcolor= $_REQUEST['bgcolor'];
$textcolor= $_REQUEST['textcolor'];
$transparent= $_REQUEST['transparent'];
$showsource= $_REQUEST['showsource'];

// defaults
if ($font=="") $font="ARIAL.TTF";
if (
$textval=="") $textval="The quick brown dog jumped over the lazy fox@spammer.com";
if (
$size=="") $size= 12;
if (
$padding=="") $padding= 2;
if (
$bgcolor=="") $bgcolor= "f0f0f0";
if (
$textcolor=="") $textcolor= "000000";
if (
$transparent=="") $transparent= 0;
if (
$size>10) $antialias= 1;
else
$antialias= 0;

// setup pt. 2
$fontfile= $fontpath.$font;

// geometry
$box= imageftbbox( $size, 0, $fontfile, $textval, array());
$boxwidth= $box[4];
$boxheight= abs($box[3]) + abs($box[5]);
$width= $boxwidth + ($padding*2) + 1;
$height= $boxheight + ($padding*2) + 0;
$textx= $padding;
$texty= ($boxheight - abs($box[3])) + $padding;
//print "$width x $height ($box[4] x ($box[3] - $box[5]))"; exit;

// create the image
$png= imagecreate($width, $height);

// colors
function mkcolor($color){
    
// courtesy simon: http://www.php.net/manual/en/function.imagecolorallocate.php#19576
    
global $png;
    
$color = str_replace("#","",$color);
    
$red = hexdec(substr($color,0,2));
    
$green = hexdec(substr($color,2,2));
    
$blue = hexdec(substr($color,4,2));
    
$out = imagecolorallocate($png, $red, $green, $blue);
    return(
$out);
    }
$bg= mkcolor($bgcolor);
$tx= mkcolor($textcolor);

// transparency
if ($transparent==1) {
    
$tbg= imagecolortransparent($png, $bg);
    }

// antialiasing
if (!$antialias) {
    
$tx= (0 - $tx);
    }

// add text
imagefttext( $png, $size, 0, $textx, $texty, $tx, $fontfile, $textval, array());

// send the image
if ($showsource=="") {
    
header("content-type: image/png");
    
imagepng($png);
    }
else {
    print
"<html>
        <head>
        <title>Labelgen.php</title>
        </head>
        <body>
        <h1>PHP Source:</h1>"
;
    
$source= show_source($_SERVER['SCRIPT_FILENAME']);
    print
"<hr />
        labelgen.php Copyright (C) 2003 by Chris Snyder<br>
        This program comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are welcome
        to redistribute it under certain conditions; please refer to the
        <a href='http://www.gnu.org/licenses/gpl.html'>GNU General Public License</a> for details.
        </body>
        </html>"
;
    }
imagedestroy($png);

?>

labelgen.php Copyright (C) 2003 by Chris Snyder
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; please refer to the GNU General Public License for details.