<?php
/*
Download for instructions and how to use...
http://rapidshare.com/files/400777995/php-image.zip
*/
// lets get the text to display
if (isset($_GET['id'])) {
$text = $_GET['id'];
}
// here you can put the default message if their's an error displaying the one in the url.
else { $text = "Default message here";}
// This is the default background image. Like a template without the text showing on it.
$bg = "bg/default.jpg";
// obvious enough. Change the size. It's height is in pixels.
$size = "30";
// just enter the hex color you want. You can use something like http://www.2createawebsite.com/build/hex-colors.html to get the color you want.
$color = "A03B3B";
// change the path to where you upload the font. It has to be .ttf but you can google and find which ever suits.
$font = "font/arial.ttf";
$im = imagecreatefromjpeg($bg);
Header("Content-type: image/png");
// This convert the hex color to RGB
$color = imagecolorallocate($im, hexdec('0x' . $color{0} . $color{1}), hexdec('0x' . $color{2} . $color{3}), hexdec('0x' . $color{4} . $color{5}));
//------ this is a fancy bit you can use if you want the text centered --------
for(;;){
// just change the figures below to where you want the exact center point of the text to be from the top left corner
$image_width = '400';
$image_height = '62';
list($left_x, $bottom_y, $right_x, , , $top_y) = imagettfbbox($size, 0, $font, $text);
$text_width = $right_x - $left_x;
$text_height = $top_y - $bottom_y;
if($image_width > $text_width+5){
break;
}
$size = $size - .5;
if($size == 1){
die('Script not responding to decreasing font size, in other words: try using less letters.');
}
}
$hpadding = ($image_width - $text_width)/2;
$vpadding = ($image_height - $text_height)/2;
//-------- End of fancy centered text bit, Delete it all if you don't want it --------
// If you not using and have deleted the fancy centered bit above you can uncomment the below two lines to put where you want to give the location of the text.
// $hpadding = '200';
// $vpadding = '100';
// Next we add the text
// FORMAT IS: image, size, angle, x distance, y distance, color, font, text string
imagettftext($im, $size, 0, $hpadding, $vpadding, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>