Giter Club home page Giter Club logo

Comments (5)

Belval avatar Belval commented on July 29, 2024

That sounds very specific, do you think you could send me the PDF to create a test case?

from pdf2image.

pierrechopin avatar pierrechopin commented on July 29, 2024

I sent you the PDF by email (I cannot share it publicly).

from pdf2image.

pierrechopin avatar pierrechopin commented on July 29, 2024

If you print like so

while index < len(data):
       file_size = data[index:].index(b'IEND') + 8 # 4 bytes for IEND + 4 bytes for CRC
       print(f"file_size {file_size} index {data[index:].index(b'IEND')} len data {len(data)}")
       images.append(Image.open(BytesIO(data[index:index+file_size])))
       index += file_size

you'll notice the data[index:].index(b'IEND') is in the middle of the file. However, calling Image.open(BytesIO(data)) works just fine, since for this file there is only one page

from pdf2image.

Belval avatar Belval commented on July 29, 2024

I was able to reproduce the issue, I will update the package this weekend or earlier.

In the meantime, while I don't know your use case, but you can probably provide an output_folder (since the resulting file are written to disk you wouldn't have this issue):

import tempfile

with tempfile.TemporaryDirectory() as path:
     images_from_path = convert_from_path('/home/belval/example.pdf', output_folder=path)
     # Do something here

Or convert using the default ppm format and then save as PNG using Pillow.

for i, img in enumerate(convert_from_bytes(pdf_data)):
    img.save(f"{i}.png")

Since PPM is a raw format, you won't have any loss in quality.

from pdf2image.

Belval avatar Belval commented on July 29, 2024

I fixed the issue and uploaded a new package to pypi. You should not be able to reproduce the bug with version 1.4.2 (at least I was not).

Thank you for taking the time to report the issue.

from pdf2image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.