diff --git a/pypdf/filters.py b/pypdf/filters.py index aa1bdc595..c990c0819 100644 --- a/pypdf/filters.py +++ b/pypdf/filters.py @@ -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" diff --git a/tests/test_filters.py b/tests/test_filters.py index 7c2b251ea..9268186aa 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -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