-
Notifications
You must be signed in to change notification settings - Fork 463
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 to new pypdfium2 API #845
Conversation
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.
Thanks a lot for the PR!
It's much appreciated that upstream projects help with the transition from one version of their project to the next 🙏 I added a few comments, let me know what you think!
I have now released pypdfium2 1.0.0 and applied the review suggestions. Could you please re-run CI? |
I need to do something to make these paths shorter.
Thanks for the ping 🙏 I'm all for loose version specifiers as long as they don't put too much constraints to avoid pushing to many env constraints on the user. So here are a few questions:
If it's only a change of import location, perhaps we could have a dynamic import depending on the version of pypfdium2. But if there are no modifications on version specifiers with this new release, then it's not worth going through this trouble and we can move forward with the PR as is :) |
Codecov Report
@@ Coverage Diff @@
## main #845 +/- ##
==========================================
- Coverage 94.84% 94.82% -0.02%
==========================================
Files 133 133
Lines 5197 5200 +3
==========================================
+ Hits 4929 4931 +2
- Misses 268 269 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
The dependency on PIL/Pillow has been made optional. This means the core library now does not have external runtime dependencies anymore. Otherwise, there are no dependency changes.
It essentially is a renaming from import pypdfium2 as pdfium
if pdfium._version.V_MAJOR == 0:
render_pdf_func = pdfium.render_pdf
else:
render_pdf_func = pdfium.render_pdf_topil
# ...
return [np.asarray(img) for img, _ in render_pdf_func(file, scale=scale, **kwargs)] However, I don't believe it's worth the additional code, considering that pypdfium2 < 1 has not been widely used.
Other parts of the public API have not changed much; it's mainly improvements under the hood. You can refer to the Changelog for more details. |
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.
Thanks a lot for the PR 🙏 Indeed with the small dependency specifier modifications, it's not worth going through the trouble of a dynamic import!
Thanks! |
Modifications to use the new pypdfium2 API (see #844).
I did not dare to try
render_pdf_tobytes()
, as I think that might change the colour format fromRGB
toBGR
.