Determine if given filename is an image.
760690
def is_image(filename):
    """"""
    # note: isfile() also accepts symlinks
    return os.path.isfile(filename) and filename.lower().endswith(ImageExts)
519920
public static function isJpegFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_JPEG)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
539396
private boolean isSessionFilename(String filename) {
        if (!StringUtils.hasText(filename)) {
            return false;
        }
        String[] parts = filename.split("_");
        // Need at least 2 parts for a valid filename
        return (parts.length >= 2);
    }
327325
def has_image(self, digest, mime_type, index, size=500):
        """"""
        cache_key = f"img:{index}:{size}:{digest}"
        return mime_type.startswith("image/") or cache_key in self.cache
334976
def determine_file_type(filename):
    
    if filename.endswith('.cls'):
        return FileType.CLS
    elif filename.endswith('.go'):
        return FileType.GO
    elif filename.endswith('.java'):
        return FileType.JAVA
    elif filename.endswith('.js'):
        return FileType.JAVASCRIPT
    elif filename.endswith('.php'):
        return FileType.PHP
    elif filename.endswith('.py'):
        return FileType.PYTHON
    elif (
        filename.endswith(
            ('.yaml', '.yml'),
        )
    ):
        return FileType.YAML
    return FileType.OTHER
991659
public static boolean isImage(String extension)
  {
    return extension != null ? IMAGE_FILE_EXTENSIONS.contains(extension.toLowerCase()) : false;
  }
339261
def is_archive(filename):
    ''''''
    for archive in archive_formats:
        if filename.endswith(archive_formats[archive]['suffix']):
            return True
    return False
117110
def _find_image_ext(path, number=None):
    """"""
    if number is not None:
        path = path.format(number)
    path = os.path.splitext(path)[0]
    for ext in _KNOWN_IMG_EXTS:
        this_path = '%s.%s' % (path, ext)
        if os.path.isfile(this_path):
            break
    else:
        ext = 'png'
    return ('%s.%s' % (path, ext), ext)
1308897
def KnowsFile(self,filename):
        """"""
        if self._isMediaFile(filename) or self._isConfigFile(filename):
            return True
        return False
66197
def image_name (txt):
    """"""
    mo = imgtag_re.search(txt)
    if mo:
        name = strformat.unquote(mo.group('name').strip())
        return  _unquote(name)
    return u''
212401
def filename_match(fsearch, filename, width, height):
    '''
    
    '''
    fsearch = clean_path(fsearch)
    filename = clean_path(filename)
    if fsearch == filename:
        return True

    if fsearch.find('@') == -1:
        return False
    basename, fileext = os.path.splitext(fsearch)
    nickname, extinfo = basename.split('@', 1)
    if extinfo == 'auto':
        valid_names = {}.fromkeys([
            nickname+'@{}x{}'.format(width, height)+fileext,
            nickname+'@{}x{}'.format(height, width)+fileext,
            nickname+'.{}x{}'.format(width, height)+fileext,
            nickname+'.{}x{}'.format(height, width)+fileext,
        ])
        if filename in valid_names:
            return True
    # if extinfo.find('x') != -1:
    #     cw, ch = extinfo.split('x', 1)
    #     if cw*width == ch*height or cw*height == ch*width:
    #         return True
    return False
75155
def canProcessFilename(cls, filename):
        
        supported_patterns = cls._extpattern_to_mime.keys()
        for pattern in supported_patterns:
            if fnmatch.fnmatch(filename, pattern):
                return True
        return False
16099
def has_image(self, name: str) -> bool:
        
        path = "docker/images/{}".format(name)
        r = self.__api.head(path)
        if r.status_code == 204:
            return True
        elif r.status_code == 404:
            return False
        self.__api.handle_erroneous_response(r)
7999
def is_pythonw(filename):
    """"""
    pattern = r'.*python(\d\.?\d*)?w(.exe)?$'
    if re.match(pattern, filename, flags=re.I) is None:
        return False
    else:
        return True
937249
def check_structure(filepath):
    """"""
    #http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupted/1401565#1401565
    
    # Check structure only for images (not supported for other types currently)
    if filepath.lower().endswith(tuple(img_filter)):
        try:
            #try:
            im = PIL.Image.open(filepath)
            #except IOError: # File format not supported by PIL, we skip the check_structure - ARG this is also raised if a supported image file is corrupted...
                #print("File: %s: DETECTNOPE" % filepath)
                #return None
            im.verify()
        # If an error occurred, the structure is corrupted
        except Exception as e:
            return str(e)
        # Else no exception, there's no corruption
        return False
    # Else the format does not currently support structure checking, we just return None to signal we didin't check
    else:
        return None
565986
public static boolean isArchiveFileName(String fileName) {
        String extension = getExtension(fileName);
        return ARCHIVE_EXTENSION_SET.contains(extension);
    }
989204
def verify_exif(filename):
    '''
    
    '''
    # required tags in IFD name convention
    required_exif = required_fields()
    exif = ExifRead(filename)
    required_exif_exist = exif.fields_exist(required_exif)
    return required_exif_exist