<?php
// Cria uma imagem 300x150
$im = imagecreatetruecolor(300, 150);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Define o fundo para branco
imagefilledrectangle($im, 0, 0, 299, 299, $white);
// Caminho para o arquivo da fonte
$font = './arial.ttf';
// Primeiramente cria-se a caixa limite
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');
// Estas são as coordenadas para X e Y
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group');
// Mostra no navegador
header('Content-Type: image/png');
imagepng($im);
?>