fix: derive crop box from coordinate extent in save_elements#4371
Open
badGarnet wants to merge 1 commit into
Open
fix: derive crop box from coordinate extent in save_elements#4371badGarnet wants to merge 1 commit into
save_elements#4371badGarnet wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Shadow auto-approve: would auto-approve. The change is a targeted bug fix in a utility function that replaces hardcoded corner indices with min/max extents, eliminating a silent crop-box inversion bug without altering core logic or adding risk.
Re-trigger cubic
aadland6
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
save_elementsassumedpoints[0]andpoints[2]were always the top-left and bottom-right corners. For elements whose coordinates carry (or were converted from) a y-up orientation, that ordering inverts the PIL crop box and raisesValueError: Coordinate 'lower' is less than 'upper'. The error was silently swallowed, so the figure/table image was dropped.The crop box is now computed from the min/max of all coordinate points, so it's always valid regardless of point ordering.
Changes
pdf_image_utils.save_elements: usemin/maxover all points instead of fixed corner indices0.22.35Summary by cubic
Fix image cropping in
pdf_image_utils.save_elementsby deriving the crop box from the coordinate extent. This prevents the PIL "Coordinate 'lower' is less than 'upper'" error and stops figure/table images from being dropped.Written for commit 0ea49ae. Summary will update on new commits.