From b6dbfdb481c1fc605c99159e6b055b876b516ba4 Mon Sep 17 00:00:00 2001 From: mara004 <geisserml@gmail.com> Date: Sun, 25 Aug 2024 17:43:53 +0200 Subject: [PATCH] Slightly simplify imgformat retrieval No need for a loop here - we can access the enum like a dictionary, which should be more efficient. --- src/img2pdf.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index f3c1548..0b7216d 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -1935,12 +1935,7 @@ def read_images( ) else: logger.debug("PIL format = %s", imgdata.format) - imgformat = None - for f in ImageFormat: - if f.name == imgdata.format: - imgformat = f - if imgformat is None: - imgformat = ImageFormat.other + imgformat = getattr(ImageFormat, imgdata.format, ImageFormat.other) def cleanup(): if imgdata is not None: