<?php
// Set the content-type
header("Content-type: image/gif");

$fontsize = 15;
if(@$_GET['fontsize']) {
    $fontsize = $_GET['fontsize'];
}
$font = 'bma.ttf';
$text = @$_GET['text'];
//$text = "teste";
// Create the image
$size = imagettfbbox($fontsize, 0, $font, $text);
$width = $size[2] + $size[0] + 8;
$height = abs($size[1]) + abs($size[7]);

$im = imagecreate($width, $height);

$colourBlack = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $colourBlack);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 63, 156, 65);

// Add the text
imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $text, array("spacing" => 0.5));

// Using imagepng() results in clearer text compared with
imagegif($im);
imagedestroy($im);
?>