if (imagetypes() IMG_GIF) {header ("Content-type: image / gif"); imagegif ($im);} elseif (imagetypes() IMG_JPG) {... etc.
참고: As of version 3.0.18 and 4.0.2 you can use the function imagetypes() in place of function_exists() for checking the presence of the various supported image formats: