From a4a7558ce7bfd38080a9b0a66d1b8aafb0d947ad Mon Sep 17 00:00:00 2001 From: Stefan <96178532+stefan6419846@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:55:34 +0100 Subject: [PATCH 1/2] BUG: Handle IndirectObject as image filter --- pypdf/filters.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pypdf/filters.py b/pypdf/filters.py index d1c06a341..659ff17bd 100644 --- a/pypdf/filters.py +++ b/pypdf/filters.py @@ -781,6 +781,9 @@ def _xobj_to_image(x_object_obj: Dict[str, Any]) -> Tuple[Optional[str], bytes, alpha = None filters = x_object_obj.get(SA.FILTER, [None]) lfilters = filters[-1] if isinstance(filters, list) else filters + if isinstance(lfilters, IndirectObject): + lfilters = lfilters.get_object() + lfilters = lfilters[-1] if isinstance(lfilters, list) else lfilters if lfilters in (FT.FLATE_DECODE, FT.RUN_LENGTH_DECODE): img, image_format, extension, _ = _handle_flate( size, From 14e09c494c936c34176d85b83d298e00565e08e8 Mon Sep 17 00:00:00 2001 From: Stefan <96178532+stefan6419846@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:16:00 +0100 Subject: [PATCH 2/2] simplify as proposed --- pypdf/filters.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pypdf/filters.py b/pypdf/filters.py index 659ff17bd..7c7c85965 100644 --- a/pypdf/filters.py +++ b/pypdf/filters.py @@ -779,11 +779,8 @@ def _xobj_to_image(x_object_obj: Dict[str, Any]) -> Tuple[Optional[str], bytes, ) extension = None alpha = None - filters = x_object_obj.get(SA.FILTER, [None]) + filters = x_object_obj.get(SA.FILTER, NullObject()).get_object() lfilters = filters[-1] if isinstance(filters, list) else filters - if isinstance(lfilters, IndirectObject): - lfilters = lfilters.get_object() - lfilters = lfilters[-1] if isinstance(lfilters, list) else lfilters if lfilters in (FT.FLATE_DECODE, FT.RUN_LENGTH_DECODE): img, image_format, extension, _ = _handle_flate( size,