Skip to content

Extracted image is being distorted #2411

@stefan6419846

Description

@stefan6419846

When extracting an image from some specific PDF file, the corresponding output file is distorted. Evince and pdfimages are able to extract correct images.

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
Linux-5.14.21-150400.24.100-default-x86_64-with-glibc2.31

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==3.17.4, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=10.1.0

Code + PDF

This is a minimal, complete example that shows the issue:

from pypdf import PdfReader


for page in PdfReader('out1.pdf').pages:
    for image in page.images:
        if image.name == "Im15.png":
            image.image.save(image.name)

I have sent the PDF file to @MartinThoma directly for privacy reasons.

Traceback

Nothing to see here, just a distorted image inside the image viewer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    workflow-imagesFrom a users perspective, image handling is the affected feature/workflow

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions