From 5acbd7a2525aa312fc57a7b9108403937fdfb60b Mon Sep 17 00:00:00 2001 From: Anton Gladky Date: Wed, 29 Dec 2021 10:15:49 +0100 Subject: [PATCH] Wrap exception on non-CMYK images into the log warning (#881) --- src/ocrmypdf/optimize.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/optimize.py b/src/ocrmypdf/optimize.py index baf38ab4..a8099d0a 100644 --- a/src/ocrmypdf/optimize.py +++ b/src/ocrmypdf/optimize.py @@ -200,7 +200,10 @@ def extract_image_generic( elif not pim.indexed and pim.colorspace in pim.SIMPLE_COLORSPACES: # An optimization opportunity here, not currently taken, is directly # generating a PNG from compressed data - pim.as_pil_image().save(png_name(root, xref)) + try: + pim.as_pil_image().save(png_name(root, xref)) + except NotImplementedError: + log.warning(f"PDF contains some images specifying non-CMYK inks. Ignoring it.") return XrefExt(xref, '.png') elif ( not pim.indexed