mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge pull request #6292 from raygard/comment_use_gif89a
Always use GIF89a for comments
This commit is contained in:
commit
2072a52bb5
|
@ -807,6 +807,9 @@ def test_comment(tmp_path):
|
|||
with Image.open(out) as reread:
|
||||
assert reread.info["comment"] == im.info["comment"].encode()
|
||||
|
||||
# Test that GIF89a is used for comments
|
||||
assert reread.info["version"] == b"GIF89a"
|
||||
|
||||
|
||||
def test_comment_over_255(tmp_path):
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
@ -817,9 +820,11 @@ 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 comments
|
||||
assert reread.info["version"] == b"GIF89a"
|
||||
|
||||
|
||||
def test_zero_comment_subblocks():
|
||||
with Image.open("Tests/images/hopper_zero_comment_subblocks.gif") as im:
|
||||
|
|
|
@ -903,17 +903,16 @@ def _get_global_header(im, info):
|
|||
# https://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
|
||||
|
||||
version = b"87a"
|
||||
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)
|
||||
):
|
||||
continue
|
||||
version = b"89a"
|
||||
break
|
||||
else:
|
||||
if im.info.get("version") == b"89a":
|
||||
version = b"89a"
|
||||
if im.info.get("version") == b"89a" or (
|
||||
info
|
||||
and (
|
||||
"transparency" in info
|
||||
or "loop" in info
|
||||
or info.get("duration")
|
||||
or info.get("comment")
|
||||
)
|
||||
):
|
||||
version = b"89a"
|
||||
|
||||
background = _get_background(im, info.get("background"))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user