Skip to content

Commit 133ccb1

Browse files
BUG: Handle IndirectObject as image filter (#2355)
Previously, we might pass "4bits" as image mode to Pillow, leading to "ValueError: unrecognized image mode". Example: `lfilters = IndirectObject(26, 0, 139771595681120)`, whose `get_object()` would yield `['/FlateDecode']` (going into the else branch of the filter handling until now).
1 parent 27409ba commit 133ccb1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pypdf/filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ def _xobj_to_image(x_object_obj: Dict[str, Any]) -> Tuple[Optional[str], bytes,
779779
)
780780
extension = None
781781
alpha = None
782-
filters = x_object_obj.get(SA.FILTER, [None])
782+
filters = x_object_obj.get(SA.FILTER, NullObject()).get_object()
783783
lfilters = filters[-1] if isinstance(filters, list) else filters
784784
if lfilters in (FT.FLATE_DECODE, FT.RUN_LENGTH_DECODE):
785785
img, image_format, extension, _ = _handle_flate(

0 commit comments

Comments
 (0)