<?php
function LoadPNG($imgname)
{
    /* Intento de abrir la imagen */
    $im = @imagecreatefrompng($imgname);
    /* Procesamiento en caso de fallo */
    if(!$im)
    {
        /* Creación de una imagen vacía */
        $im  = imagecreatetruecolor(150, 30);
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
        /* Se muestra un mensaje de error */
        imagestring($im, 1, 5, 5, 'Error de carga ' . $imgname, $tc);
    }
    return $im;
}
header('Content-Type: image/png');
$img = LoadPNG('bogus.image');
imagepng($img);
?>
    
   Resultado del ejemplo anterior es similar a: