From 132464c0a1ce199e3af2be8dca39bb4aa7691686 Mon Sep 17 00:00:00 2001 From: mara004 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 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index f89670b..76439c3 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -1832,11 +1832,9 @@ 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: + try: + imgformat = ImageFormat[imgdata.format] + except KeyError: imgformat = ImageFormat.other def cleanup():