<?php
function PNGyükle($ad)
{
    /* Görüntüyü açmaya çalışalım */
    $im = @imagecreatefrompng($ad);
    /* Başarılı oldu mu bakalım */
    if(!$im)
    {
        /* Boş bir görüntü oluşturalım */
        $im  = imagecreatetruecolor (20, 20);
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 10, 10, $bgc);
        /* Hata iletisini çıktılayalım */
        imagestring($im, 1, 5, 5, $ad . ' yüklenirken hata oluştu', $tc);
    }
    return $im;
}
header('Content-Type: image/png');
$img = PNGyükle('bozuk.görüntü');
imagepng($img);
imagedestroy($img);
?>
    
   
Yukarıdaki örnek şuna benzer bir çıktı üretir: