rendered paste body<?
// Options
$fontsize = 24;
$font = "AntsyPants";
$text = "TESTing";
$background_color = "grey";
$font_color = "blue";
$image_type = "GIF";
$padding = 25; // Padding in pixels.
$shadow_distance = 2; // Distance of Shadow from Text
// Determine font
if ( $font == "AntsyPants" )
{
$font = 'AntsyPants.ttf';
}
$boundingbox = @imagettfbbox($fontsize, 0, $font, $text);
$text_width = abs($boundingbox[4] - $boundingbox[0]);
$text_height = abs($boundingbox[5] - $boundingbox[1]);
$imagewidth = $text_width + ($padding * 2);
$imageheight = $text_height + ($padding * 2);
// Create the Image
$im = imagecreatetruecolor($imagewidth, $imageheight);
$xcord = ($imagewidth / 2) - ($text_width / 2);
$ycord = ($imageheight / 2) + ($text_height / 2) - 2;
// Fill Background
switch ($background_color)
{
case 'grey':
$color = imagecolorallocate($im, 128, 128, 128);
break;
case 'black':
$color = imagecolorallocate($im, 0, 0, 0);
break;
case 'blue':
$color = imagecolorallocate($im, 14, 37, 216);
break;
case 'white':
default:
$color = imagecolorallocate($im, 255, 255, 255);
break;
}
imagefilledrectangle($im, 0, 0, $imagewidth, $imageheight, $color);
// Create Text
switch ($font_color)
{
case 'grey':
$color = imagecolorallocate($im, 128, 128, 128);
break;
case 'white':
$color = imagecolorallocate($im, 255, 255, 255);
break;
case 'blue':
$color = imagecolorallocate($im, 14, 37, 216);
break;
case 'black':
default:
$color = imagecolorallocate($im, 0, 0, 0);
break;
}
// Display Shadow
$shadow = imagecolorallocate($im, 60, 60, 60);
imageTTFText($im, $fontsize, 0, $xcord + $shadow_distance, $ycord + $shadow_distance, $shadow, $font, $text);
// Display Text
imageTTFText($im, $fontsize, 0, $xcord, $ycord, $color, $font, $text);
// Display Image
if ( $image_type == "GIF" )
{
header("Content-type: image/gif");
imagegif($im);
}
elseif ( $image_type == "JPG" )
{
header("Content-type: image/jpg");
imagejpeg($im);
}
elseif ( $image_type == "PNG" )
{
header("Content-type: image/png");
imagepng($im);
}
// Destroy Image
imagedestroy($im);
?>