-
Notifications
You must be signed in to change notification settings - Fork 684
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
Inconsistent results when cropping an already cropped page #245
Comments
Thanks for flagging this, @samkit-jain! I think this is what's happening:
I can see a handful of potential solutions:
Thoughts? |
What is the reasoning behind this?
If by this you mean that the cropped page would be treated as a "real" page and all the operations like |
Great question; I should have elaborated earlier. The answer: Mostly for simplicity. A page's bounding box should, I think, exist in the same coordinate system as each object on the page. So changing the coordinates of the bounding box would mean changing the coordinates of all objects in the resulting cropped page. To me, ensuring that all coordinates relevant to all objects were moved post-crop seemed a tricky task. To take an oversimplified example: Let's say a page's original bounding box was
The more I think about this, I think I prefer the following combination of improvements:
|
Thanks for the explanation. +1 for the warning. Also, adding a new |
Addresses #245 Also adds `relative` param to .within_bbox, and adds a new utils.calculate_area(bbox) method.
h/t @samkit-jain for catching, per example in #245
h/t @samkit-jain for catching, per example in #245
Closing now, as resolved in two commits referenced above and available in v0.5.23. Thanks again for raising the issue! |
Describe the bug
When cropping an already cropped page, the objects are not preserved.
Code to reproduce the problem
PDF file
examples/pdfs/ag-energy-round-up-2017-02-24.pdf
Expected behavior
bottom.png
- The bottom portion of the page is saved.bottom_left.png
- The left half of bottom portion of the page is saved.bottom_right.png
- The right half of the bottom portion of the page is saved.Actual behavior
bottom.png
- The bottom portion of the page is saved.bottom_left.png
- The left half of the top portion of the page is saved.bottom_right.png
- The right half of the top portion of the page is saved.Screenshots
bottom.png
bottom_left.png
bottom_right.png
Environment
Additional context
The issue was found when working on #244
The text was updated successfully, but these errors were encountered: