提交 23658296 编写于 作者: littletomatodonkey's avatar littletomatodonkey

fix image list postfix

上级 10880fc1
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
import logging import logging
import os import os
import imghdr
def initial_logger(): def initial_logger():
...@@ -61,13 +62,14 @@ def get_image_file_list(img_file): ...@@ -61,13 +62,14 @@ def get_image_file_list(img_file):
if img_file is None or not os.path.exists(img_file): if img_file is None or not os.path.exists(img_file):
raise Exception("not found any img file in {}".format(img_file)) raise Exception("not found any img file in {}".format(img_file))
img_end = ['jpg', 'png', 'jpeg', 'JPEG', 'JPG', 'bmp'] img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff'}
if os.path.isfile(img_file) and img_file.split('.')[-1] in img_end: if os.path.isfile(img_file) and imghdr.what(img_file) in img_end:
imgs_lists.append(img_file) imgs_lists.append(img_file)
elif os.path.isdir(img_file): elif os.path.isdir(img_file):
for single_file in os.listdir(img_file): for single_file in os.listdir(img_file):
if single_file.split('.')[-1] in img_end: file_path = os.path.join(img_file, single_file)
imgs_lists.append(os.path.join(img_file, single_file)) if imghdr.what(file_path) in img_end:
imgs_lists.append(file_path)
if len(imgs_lists) == 0: if len(imgs_lists) == 0:
raise Exception("not found any img file in {}".format(img_file)) raise Exception("not found any img file in {}".format(img_file))
return imgs_lists return imgs_lists
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册