Always use GIF89a for long comments

Fix bug that allows GIFs with long comments to be written as GIF87a.
This commit is contained in:
Ray Gardner 2022-05-13 11:33:33 -06:00
parent 9c580ce649
commit b3d29e946a
2 changed files with 3 additions and 2 deletions

View File

@ -804,8 +804,9 @@ def test_comment_over_255(tmp_path):
im.info["comment"] = comment
im.save(out)
with Image.open(out) as reread:
assert reread.info["comment"] == comment
# Test that GIF89a is used for long comment
assert reread.info["version"] == b"GIF89a"
def test_zero_comment_subblocks():

View File

@ -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
):
continue
version = b"89a"