How to extract not original images but cropped images #3969
-
Hello, Thank you for your great work on this project! I would like to know how I can extract the cropped portion of images in a PDF, instead of the original, uncropped images. Currently, I'm able to extract the original images using page.get_image_bbox(), but this doesn't account for images that are cropped on the page. What I need is to extract only the part of the image that is visible on the PDF page, excluding the portions that may have been cropped out. Here’s my code along with the input PDF and the output images:
Here is my original pdf. Extrated images Ideal extracted images Could you please guide me on how to modify the code to achieve this? Thank you for your assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is no issue, but a typical Discussions item ... transferring. |
Beta Was this translation helpful? Give feedback.
-
This is not easy to achieve, because there is no definition of what "cropped" means. |
Beta Was this translation helpful? Give feedback.
This is not easy to achieve, because there is no definition of what "cropped" means.
Like in your example: you did not crop anything - you just covered some of the image parts. There is no way of determining which parts have remained visible.
If you however know the window of visibility, the obviously most canonic way is to make a pixmap of that region and save it.