-
Notifications
You must be signed in to change notification settings - Fork 455
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
Switch PDF page rendering to an iterator format #1040
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1040 +/- ##
==========================================
- Coverage 94.93% 94.91% -0.02%
==========================================
Files 135 135
Lines 5625 5626 +1
==========================================
Hits 5340 5340
- Misses 285 286 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -42,4 +42,5 @@ def read_pdf( | |||
|
|||
# Rasterise pages to PIL images with pypdfium2 and convert to numpy ndarrays | |||
with pdfium.PdfDocument(file, password=password) as pdf: | |||
return [np.asarray(img) for img in pdf.render_topil(scale=scale, **kwargs)] | |||
for img in pdf.render_topil(scale=scale, **kwargs): | |||
yield np.asarray(img) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be a one-liner:
yield from pdf.render_topil(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh looks a bit strange 😅
yield from np.asarray(pdf.render_topil(...))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I see! Overlooked that in the hurry. I expect it'll be better once I have released v3 so that you can use render_tonumpy()
, see #1032.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A got it would you link the discussion to the issue ? :) So i would close this PR until your release is finally
While this PR changes |
Yeah that's correct... was a bit to fast with this |
Waiting until #1032 |
No problem. I agree it's best to postpone this until I'm through with v3. |
Yeah no stress.. wrote with @charlesmindee today .. next release will be next month :) So enough time ^^ |
Good to know. I want to do a thorough reversion of my codebase so I don't need to make another API-breaking release too soon. But I do expect I'll finish it within a month at the most. |
This PR:
Closses:
#1001