Skip to content

Commit

Permalink
BUG: Handle IndirectObject as image filter (#2355)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
stefan6419846 authored Dec 23, 2023
1 parent 27409ba commit 133ccb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ 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 lfilters in (FT.FLATE_DECODE, FT.RUN_LENGTH_DECODE):
img, image_format, extension, _ = _handle_flate(
Expand Down

0 comments on commit 133ccb1

Please sign in to comment.