From cbd812bc9936e5726321bdef1fb8ed1b4a4da46f Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 4 Mar 2021 19:51:26 +0800 Subject: [PATCH] fix issue 2086 --- ppocr/utils/utility.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ppocr/utils/utility.py b/ppocr/utils/utility.py index 29576d97..5e5bddb0 100755 --- a/ppocr/utils/utility.py +++ b/ppocr/utils/utility.py @@ -14,7 +14,6 @@ import logging import os -import imghdr import cv2 @@ -52,12 +51,14 @@ def get_image_file_list(img_file): raise Exception("not found any img file in {}".format(img_file)) img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif', 'GIF'} - if os.path.isfile(img_file) and imghdr.what(img_file) in img_end: + if os.path.isfile(img_file) and os.path.splitext(img_file)[-1][ + 1:] in img_end: imgs_lists.append(img_file) elif os.path.isdir(img_file): for single_file in os.listdir(img_file): file_path = os.path.join(img_file, single_file) - if os.path.isfile(file_path) and imghdr.what(file_path) in img_end: + if os.path.isfile(file_path) and os.path.splitext(file_path)[-1][ + 1:] in img_end: imgs_lists.append(file_path) if len(imgs_lists) == 0: raise Exception("not found any img file in {}".format(img_file)) @@ -76,4 +77,4 @@ def check_and_read_gif(img_path): frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB) imgvalue = frame[:, :, ::-1] return imgvalue, True - return None, False \ No newline at end of file + return None, False -- GitLab