<?php
// Creación de una imagen de 300x150 píxeles
$im = imagecreatetruecolor(300, 150);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Define el fondo en blanco
imagefilledrectangle($im, 0, 0, 299, 299, $white);
// Ruta hacia nuestro archivo de fuente
$font = './arial.ttf';
// Primero, creamos un rectángulo que contenga nuestro texto
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');
// Nuestras coordenadas en X y en 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');
// Muestra hacia el navegador
header('Content-Type: image/png');
imagepng($im);
?>