Skip to content

Commit

Permalink
BUG: fix image look-up table in EncodedStreamObject
Browse files Browse the repository at this point in the history
closes py-pdf#2124
closes py-pdf#2110
  • Loading branch information
pubpub-zz committed Aug 28, 2023
1 parent 0ab320c commit 9188157
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
ArrayObject,
DecodedStreamObject,
DictionaryObject,
EncodedStreamObject,
IndirectObject,
NullObject,
)
Expand Down Expand Up @@ -860,7 +861,7 @@ def bits2byte(data: bytes, size: Tuple[int, int], bits: int) -> bytes:
if color_space == "/Indexed":
from .generic import TextStringObject

if isinstance(lookup, DecodedStreamObject):
if isinstance(lookup, (EncodedStreamObject, DecodedStreamObject)):
lookup = lookup.get_data()
if isinstance(lookup, TextStringObject):
lookup = lookup.original_bytes
Expand Down
9 changes: 9 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,12 @@ def test_jpx_no_spacecode():
with pytest.raises(PdfReadError) as exc:
reader.pages[0].images[0]
assert exc.value.args[0].startswith("ColorSpace field not found")


@pytest.mark.enable_socket()
def test_encodedstream_lookup():
"""From #2124"""
url = "https://github.com/py-pdf/pypdf/files/12455580/10.pdf"
name = "iss2124.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
reader.pages[12].images[0]

0 comments on commit 9188157

Please sign in to comment.