Skip to content

STY: Add two abbreviations for an inline image object #3048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,10 @@ def decode_stream_data(stream: Any) -> bytes:
data = FlateDecode.decode(data, params)
elif filter_name in (FT.RUN_LENGTH_DECODE, FTA.RL):
data = RunLengthDecode.decode(data)
elif filter_name == FT.CCITT_FAX_DECODE:
elif filter_name in (FT.CCITT_FAX_DECODE, FTA.CCF):
height = stream.get(IA.HEIGHT, ())
data = CCITTFaxDecode.decode(data, params, height)
elif filter_name == FT.DCT_DECODE:
elif filter_name in (FT.DCT_DECODE, FTA.DCT):
data = DCTDecode.decode(data)
elif filter_name == FT.JPX_DECODE:
data = JPXDecode.decode(data)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,30 @@ def test_ccitt_fax_decode():
)


def test_ccitt_fax_decode_and_ccf():
data = RESOURCE_ROOT.joinpath("imagemagick-CCITTFaxDecode.pdf").read_bytes()
reader = PdfReader(BytesIO(data))
image1 = reader.pages[0].images[0].data

data = data.replace(b"/CCITTFaxDecode", b"/CCF")
reader = PdfReader(BytesIO(data))
image2 = reader.pages[0].images[0].data

assert image1 == image2


def test_dct_decode_and_dct():
data = RESOURCE_ROOT.joinpath("jpeg.pdf").read_bytes()
reader = PdfReader(BytesIO(data))
image1 = reader.pages[0].images[0].data

data = data.replace(b"/DCTDecode", b"/DCT")
reader = PdfReader(BytesIO(data))
image2 = reader.pages[0].images[0].data

assert image1 == image2


@pytest.mark.enable_socket
def test_decompress_zlib_error(caplog):
reader = PdfReader(BytesIO(get_data_from_url(name="tika-952445.pdf")))
Expand Down
Loading