Skip to content

Instantly share code, notes, and snippets.

@Jojozzc
Created December 4, 2018 06:35
Show Gist options
  • Save Jojozzc/3f3c461d52d4ead963aeaab92af0aa0e to your computer and use it in GitHub Desktop.
Save Jojozzc/3f3c461d52d4ead963aeaab92af0aa0e to your computer and use it in GitHub Desktop.
judge whether a file's name is image format
import re
def is_img_file(file_name):
file_name = str(file_name)
file_name = file_name.lower()
return re.search('\.bmp$', file_name) or re.search('\.png$', file_name) or \
re.search('\.jpg$', file_name) or re.search('\.jpeg', file_name) or re.search('\.tiff', file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment