ImageTools::checkFile(). Optimized extension detection.