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():