What is the best and fastest way to check if the image is valid in PHP ? I need it to be able to check GIF, JPG as well as PNG images.
exif_imagetype is much faster than getimagesize and doesn't use gd-Lib (leaving a leaner mem footprint)
function isImage($pathToFile) { if( false === exif_imagetype($pathToFile) ) return FALSE; return TRUE; }