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

Read bounding box information from the trailer of EPS files if specified #7382

Merged
merged 10 commits into from Oct 1, 2023

Conversation

nopperl
Copy link
Contributor

@nopperl nopperl commented Sep 7, 2023

The bounding box for EPS images is currently only parsed from the file header. However, the DSC specification also allows it to be specified in the trailer (see Section 4.6 of the specification). According to the specification, this must be indicated in the header using %%BoundingBox: (atend). The real bounding box information is then specified at the end of the file following the %%Trailer comment. For an example, see Tests/images/zero_bb_trailer.eps.

Currently, the EpsImagePlugin tries to parse the bounding box only from the header, which fails if the value is (atend). This PR fixes the error and implements boundary box parsing from the trailer.

Tests/test_file_eps.py Outdated Show resolved Hide resolved
@radarhere
Copy link
Member

I'm guessing you created the test image by opening up one of our existing test images in a text editor and modifying it manually?

@nopperl
Copy link
Contributor Author

nopperl commented Sep 11, 2023

Yes, I simply modified zero_bb.eps because I can't distribute the images I've worked with. Should it be a "real" image instead?

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
@radarhere
Copy link
Member

Not necessarily, no. Real images are certainly ideal, but created ones are also accepted, as it's not always possible/practical to find an image that triggers a certain scenario.

Last trailer comment has priority
@radarhere radarhere merged commit 43e6826 into python-pillow:main Oct 1, 2023
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants