Skip to content
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

rectangular (image) selection #52

Open
rhaynes74 opened this issue Jan 4, 2022 · 10 comments
Open

rectangular (image) selection #52

rhaynes74 opened this issue Jan 4, 2022 · 10 comments

Comments

@rhaynes74
Copy link

Hi folks, thanks for your efforts with this tool. I was wondering if there are plans to add rectangular (image) selection to the tool?
The workflow that I imagine would be to select figures / tables / formulas using the often available rectangular selection, and then have those selection saved as images (.png, .jpg, etc...) and included as links in the markdown file.

@0xabu
Copy link
Owner

0xabu commented Jan 4, 2022

Thanks for the suggestion. This sounds like a reasonable idea for a feature, but it's also not something I'm likely to work on soon as it's not directly relevant to my use-case... I'd be happy to review PRs.

@liang-0131
Copy link

I need that too

@thiswillbeyourgithub
Copy link

thiswillbeyourgithub commented Apr 26, 2022

Badly needed here too :)
as well as #39 to import my okular collection to logseq

@thiswillbeyourgithub
Copy link

@0xabu would you by any chance have a recommended best way to extract an image rendering of a pdf given the precise bounding box location ? I am willing to try to implement this in the coming months.

@0xabu
Copy link
Owner

0xabu commented May 14, 2022

@thiswillbeyourgithub not really, sorry. pdfminer already has the ability to extract images as bitmaps (see calls to render_image in https://github.com/pdfminer/pdfminer.six/blob/master/pdfminer/converter.py), but I'm not sure about capturing an arbitrary section of the page.

@thiswillbeyourgithub
Copy link

thiswillbeyourgithub commented May 15, 2022

After looking a bit into it it appears that pdfminer is quite complicated to get into. I want to spend as little time on it as possible when i'll get to it so :

If I were to simply:

Would you find this a satisfactory PR or that that seem to hacky for you ? Of course with a bit of optimization to avoid converting useless pages etc.

Another possibility would be to open an issue in the pdfminer github and ask them their opinion.

@0xabu
Copy link
Owner

0xabu commented May 15, 2022

I'm not excited about that approach, sorry -- it would add both pdf2image and PIL as dependencies (and from what I can see pdf2image itself just shells out to poppler utils). pdfminer has a gitter chat, maybe you could ask for advice there, or look around at some of the other apps that build on top of pdfminer for inspiration?

@thiswillbeyourgithub
Copy link

Thank you for the quick answer. Can you take a look at this comment in the github of pdfminer ? Would using py-pdf-parser be an acceptal PR by your standard or not ?

@0xabu
Copy link
Owner

0xabu commented May 25, 2022

I looked at py-pdf-parser, if you look here it appears to be relying on wand (which is a python wrapper for imagemagick) to convert pdf pages to bitmaps. The rest of py-pdf-parser is irrelevant for us.

I think I would be ok with adding wand as an optional dependency, so if it is not present, then the image export functionality doen't work, but you don't need it to keep using pdfannots as today.

@thiswillbeyourgithub
Copy link

Alright. Thank you very much. I intend to do this in the summer probably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants