-
Notifications
You must be signed in to change notification settings - Fork 19
Add the PDF Image loader #1
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
Conversation
|
After some reconsideration, I think it would probably be better if the But there are definitely some drawbacks. And in order to implement this function, we need some modifications for the |
|
kyleclo
left a comment
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.
,lgtm
mmda/types/image.py
Outdated
| def tobase64(self): | ||
| # Ref: https://stackoverflow.com/a/31826470 | ||
| buffered = BytesIO() | ||
| self.save(buffered, format="JPEG") |
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.
why not png?
|
|
||
| # Monkey patch the PIL.Image methods to add base64 conversion | ||
|
|
||
| def tobase64(self): |
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.
do we want to support 2 forms: base64 and proper image file that one can download & view
| img = Image.open(buffered) | ||
| return img | ||
|
|
||
| Image.Image.tobase64 = tobase64 # This is the method applied to individual Image classes |
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.
prefer we define our own Image class, inherit from PIL's Image class, and override the methods.
| from mmda.types.image import Image | ||
|
|
||
|
|
||
| class BaseParser: |
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.
why the rename?
| Sent: [], | ||
| Block: [] | ||
| Block: [], | ||
| DocImage: [], |
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.
add inline comment saying this is loaded into doc in parse()
No description provided.