Created
December 4, 2018 06:35
-
-
Save Jojozzc/3f3c461d52d4ead963aeaab92af0aa0e to your computer and use it in GitHub Desktop.
judge whether a file's name is image format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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