Bu örnek betik, içinde Arial yazı tipi ile siyah renkte (gri gölgeli)
"Testing..." yazılmış 400x30 piksellik beyaz bir PNG görüntü üretecektir.
<?php
// İçerik türünü belirt
header('Content-Type: image/png');
// Görüntüyü boş olarak oluştur
$resim = imagecreatetruecolor(400, 30);
// Renkleri tanımla
$beyaz = imagecolorallocate($resim, 255, 255, 255);
$gri = imagecolorallocate($resim, 128, 128, 128);
$siyah = imagecolorallocate($resim, 0, 0, 0);
imagefilledrectangle($resim, 0, 0, 399, 29, $beyaz);
// Metni tanımla
$metin = 'Testing...';
// Buraya kendi dosya yolunuzu yaz
$font = 'arial.ttf';
// Metne gölge ver
imagettftext($resim, 20, 0, 11, 21, $gri, $font, $metin);
// Metni ekle
imagettftext($resim, 20, 0, 10, 20, $siyah, $font, $metin);
// imagejpeg()'ye göre daha temiz sonuç veren imagepng()'yi kullan
imagepng($resim);
imagedestroy($resim);
?>
Yukarıdaki örnek şuna benzer bir çıktı üretir: