Skip to content

Commit

Permalink
BUG: Fix conversion from 1 to LA (#2175)
Browse files Browse the repository at this point in the history
Closes #2165
Closes #2176
  • Loading branch information
pubpub-zz authored Sep 9, 2023
1 parent bd73243 commit 5bfbae7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ def _handle_jpx(
alpha = alpha.convert("L")
if img.mode == "P":
img = img.convert("RGB")
elif img.mode == "1":
img = img.convert("L")
img.putalpha(alpha)
if "JPEG" in image_format:
extension = ".jp2"
Expand Down
10 changes: 10 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,13 @@ def test_encodedstream_lookup():
name = "iss2124.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
reader.pages[12].images[0]


@pytest.mark.enable_socket()
def test_convert_1_to_la():
"""From #2165"""
url = "https://github.com/py-pdf/pypdf/files/12543290/whitepaper.WBT.token.blockchain.whitepaper.pdf"
name = "iss2165.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
for i in reader.pages[13].images:
_ = i

0 comments on commit 5bfbae7

Please sign in to comment.