naturalmente il tutto preceduto da
header('Content-Type: image/gif');