-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Always use GIF89a for comments #6292
Conversation
Fix bug that allows GIFs with long comments to be written as GIF87a.
src/PIL/GifImagePlugin.py
Outdated
@@ -915,7 +915,7 @@ def _get_global_header(im, info): | |||
for extensionKey in ["transparency", "duration", "loop", "comment"]: | |||
if info and extensionKey in info: | |||
if (extensionKey == "duration" and info[extensionKey] == 0) or ( | |||
extensionKey == "comment" and not (1 <= len(info[extensionKey]) <= 255) | |||
extensionKey == "comment" and len(info[extensionKey]) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extensionKey == "comment" and len(info[extensionKey]) == 0 | |
extensionKey == "comment" and info[extensionKey] |
This seems simpler to me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@radarhere, thank you for reviewing my PR.
The test needs to determine that info[comment]
is an empty string to keep version
as 87a
. Your suggestion info[extensionKey]
does the opposite. I was attempting to extrapolate from not (1 <= len(info[extensionKey]) <= 255)
(which originated with PR #1896 but was superseded by PR #3479) to retain the length test. I think it probably could be info[extensionKey] == ""
or even not info[extensionKey]
. The 255 was there to begin with, I think, to fit with the maximum length of the single data block
that was allowed before PR #3479.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - I meant not info[extensionKey]
. That was just a mistake on my part.
This forces GIF89a for all comments, not just "long comments". So wouldn't it be more straightforward to modify |
Pillow already uses GIF89a for shorter comments, so adding |
Ok, thanks. That's perfectly fair. |
I've created https://github.com/raygard/Pillow/pull/1 with a suggestion from me, to add the check to |
Simplified version check
Fix bug that allows GIFs with long comments to be written as GIF87a.
Fixes #6291 .
Changes proposed in this pull request:
_get_global_header()
to use GIF89a for long comments.test_comment_over_255()
to check this.