The best I could find, an if
fclose
fopen
type thing, makes the page load really slowly.
Basically what I\'m trying to do is
To check for the existence of images, exif_imagetype should be preferred over getimagesize, as it is much faster.
To suppress the E_NOTICE
, just prepend the error control operator (@
).
if (@exif_imagetype($filename)) {
// Image exist
}
As a bonus, with the returned value (IMAGETYPE_XXX
) from exif_imagetype
we could also get the mime-type or file-extension with image_type_to_mime_type
/ image_type_to_extension
.