Skip to content

Commit c0aa032

Browse files
committed
BUG: fix convertion from 1 to LA
closes py-pdf#2165
1 parent 05f2a65 commit c0aa032

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pypdf/filters.py

+2
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,8 @@ def _handle_jpx(
10971097
alpha = alpha.convert("L")
10981098
if img.mode == "P":
10991099
img = img.convert("RGB")
1100+
elif img.mode == "1":
1101+
img = img.convert("L")
11001102
img.putalpha(alpha)
11011103
if "JPEG" in image_format:
11021104
extension = ".jp2"

tests/test_filters.py

+10
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,13 @@ def test_encodedstream_lookup():
594594
name = "iss2124.pdf"
595595
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
596596
reader.pages[12].images[0]
597+
598+
599+
@pytest.mark.enable_socket()
600+
def test_convert_1_to_la():
601+
"""From #2165"""
602+
url = "https://github.com/py-pdf/pypdf/files/12543290/whitepaper.WBT.token.blockchain.whitepaper.pdf"
603+
name = "iss2165.pdf"
604+
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
605+
for i in reader.pages[13].images:
606+
_ = i

0 commit comments

Comments
 (0)