Skip to content

Commit 35be391

Browse files
authored
BUG: Accept calRGB and calGray color_spaces (#1968)
Fixes #1956
1 parent c864f4e commit 35be391

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pypdf/filters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@ def _get_imagemode(
656656
raise PdfReadError(
657657
"can not interprete colorspace", color_space
658658
) # pragma: no cover
659+
elif color_space[0].startswith("/Cal"): # /CalRGB and /CalGray
660+
color_space = "/Device" + color_space[0][4:]
659661
elif color_space[0] == "/ICCBased":
660662
icc_profile = color_space[1].get_object()
661663
color_components = cast(int, icc_profile["/N"])

tests/test_filters.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,14 @@ def test_cascaded_filters_images():
440440
_ = i.name, i.image
441441

442442

443+
@pytest.mark.enable_socket()
444+
def test_calrgb():
445+
url = "https://github.com/py-pdf/pypdf/files/12061061/tt.pdf"
446+
name = "calRGB.pdf"
447+
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name)))
448+
reader.pages[0].images[0]
449+
450+
443451
@pytest.mark.enable_socket()
444452
def test_2bits_image():
445453
"""From #1954, test with 2bits image. TODO: 4bits also"""

0 commit comments

Comments
 (0)