fix: derive crop box from coordinate extent in `save_elements` (#4371)
`save_elements` assumed `points[0]` and `points[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 raises `ValueError: 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`: use `min/max` over all points instead of fixed corner indices - Added a regression test for inverted/rotated coordinate ordering - CHANGELOG + version bump to `0.22.35` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix image cropping in `pdf_image_utils.save_elements` by 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. - **Bug Fixes** - Compute the crop box with min/max over all points instead of assuming fixed corners. - Add a regression test for inverted/rotated coordinate ordering. <sup>Written for commit 0ea49ae7a0c0102e938994a808ad243c6d281a4d. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/Unstructured-IO/unstructured/pull/4371?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Y
Yao You committed
f4105db674e4bf6c98ddb8fe6a5e32df0d7237b4
Parent: 2c0c7a6
Committed by GitHub <noreply@github.com>
on 10/5/2026, 1:07:29 AM