pypdf icon indicating copy to clipboard operation
pypdf copied to clipboard

Extracted image is being distorted

Open stefan6419846 opened this issue 5 months ago • 0 comments

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.

stefan6419846 avatar Jan 15 '24 15:01 stefan6419846