mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #1 from radarhere/comment_use_gif89a
Simplified version check
This commit is contained in:
commit
882c04b08a
|
@ -794,6 +794,9 @@ def test_comment(tmp_path):
|
||||||
with Image.open(out) as reread:
|
with Image.open(out) as reread:
|
||||||
assert reread.info["comment"] == im.info["comment"].encode()
|
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):
|
def test_comment_over_255(tmp_path):
|
||||||
out = str(tmp_path / "temp.gif")
|
out = str(tmp_path / "temp.gif")
|
||||||
|
@ -805,7 +808,8 @@ def test_comment_over_255(tmp_path):
|
||||||
im.save(out)
|
im.save(out)
|
||||||
with Image.open(out) as reread:
|
with Image.open(out) as reread:
|
||||||
assert reread.info["comment"] == comment
|
assert reread.info["comment"] == comment
|
||||||
# Test that GIF89a is used for long comment
|
|
||||||
|
# Test that GIF89a is used for comments
|
||||||
assert reread.info["version"] == b"GIF89a"
|
assert reread.info["version"] == b"GIF89a"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -912,17 +912,16 @@ def _get_global_header(im, info):
|
||||||
# https://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
|
# https://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
|
||||||
|
|
||||||
version = b"87a"
|
version = b"87a"
|
||||||
for extensionKey in ["transparency", "duration", "loop", "comment"]:
|
if im.info.get("version") == b"89a" or (
|
||||||
if info and extensionKey in info:
|
info
|
||||||
if (extensionKey == "duration" and info[extensionKey] == 0) or (
|
and (
|
||||||
extensionKey == "comment" and len(info[extensionKey]) == 0
|
"transparency" in info
|
||||||
):
|
or "loop" in info
|
||||||
continue
|
or info.get("duration")
|
||||||
version = b"89a"
|
or info.get("comment")
|
||||||
break
|
)
|
||||||
else:
|
):
|
||||||
if im.info.get("version") == b"89a":
|
version = b"89a"
|
||||||
version = b"89a"
|
|
||||||
|
|
||||||
background = _get_background(im, info.get("background"))
|
background = _get_background(im, info.get("background"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user