From 6c8852eb04423317bc3793d6663f6c491a56b5d7 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Thu, 22 Apr 2021 13:12:40 +0200 Subject: [PATCH] check_dpi: catch Pillow choking on faulty img, return 230 --- qurator/eynollah/utils/pil_cv2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qurator/eynollah/utils/pil_cv2.py b/qurator/eynollah/utils/pil_cv2.py index 4d180f5..20dc22f 100644 --- a/qurator/eynollah/utils/pil_cv2.py +++ b/qurator/eynollah/utils/pil_cv2.py @@ -15,13 +15,13 @@ def pil2cv(img): return cvtColor(pil_as_np_array, color_conversion) def check_dpi(img): - if isinstance(img, Image.__class__): - pil_image = img - elif isinstance(img, str): - pil_image = Image.open(img) - else: - pil_image = cv2pil(img) try: + if isinstance(img, Image.__class__): + pil_image = img + elif isinstance(img, str): + pil_image = Image.open(img) + else: + pil_image = cv2pil(img) exif = OcrdExif(pil_image) resolution = exif.resolution if resolution == 1: