-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix Name field length when saving IM images #4424
Conversation
This comment has been minimized.
This comment has been minimized.
Rearranged code for Windows
My personal opinion, in the case of
to be slightly odd. I would feel better about just trimming it down to the base name in this situation, because I don't think I need to know the absolute path of an image's original location.
|
Sounds sensible, updated. Of course, it's technically possible for a long basename to exceed the limit. This is less likely, do we fix it, or let it be until someone stumbles over it? There's an easy workaround. I doubt the IM format gets much use, pretty much the only references I could find online for the format were in PIL/Pillow. |
Trim end of name, keeping ext
For #4193.
Converting
Tests/test_file_im.py
to use pytest surfaced a bug in saving IM format files.When roundtripping the file, it failed opening the saved file, at this check:
Pillow/src/PIL/ImImagePlugin.py
Lines 155 to 156 in 29fee8f
It's falling over the
Name:
field, which is saved like this:Pillow/src/PIL/ImImagePlugin.py
Lines 349 to 350 in 29fee8f
The difference is the temp path+filename under the limit with
PillowTestCase.tempfile
:And over the limit with pytest's
tmp_path
:This PR trims the path+filename to fit, and I suggest to keep the last part which includes the filename and extension, rather than cropping it off.