mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Multiple GIF comments in a frame are separated
If more than one comment is in a GIF frame, separate them with \r\n in the info dict.
This commit is contained in:
parent
c4325c805e
commit
44c6467400
BIN
Tests/images/multiple_comments.gif
Normal file
BIN
Tests/images/multiple_comments.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -813,6 +813,12 @@ def test_zero_comment_subblocks():
|
|||
assert_image_equal_tofile(im, TEST_GIF)
|
||||
|
||||
|
||||
def test_read_multiple_comments():
|
||||
with Image.open("Tests/images/multiple_comments.gif") as im:
|
||||
# Multiple comments in a frame are separated not concatenated
|
||||
assert im.info["comment"] == b"Test comment 1\r\nTest comment 2"
|
||||
|
||||
|
||||
def test_version(tmp_path):
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
||||
|
|
|
@ -228,12 +228,17 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
#
|
||||
# comment extension
|
||||
#
|
||||
# Collect one comment block
|
||||
comment = b""
|
||||
while block:
|
||||
if "comment" in info:
|
||||
info["comment"] += block
|
||||
else:
|
||||
info["comment"] = block
|
||||
comment += block
|
||||
block = self.data()
|
||||
|
||||
# If multiple comments in frame, separate in info with \r\n
|
||||
if "comment" in info:
|
||||
info["comment"] += b"\r\n" + comment
|
||||
else:
|
||||
info["comment"] = comment
|
||||
s = None
|
||||
continue
|
||||
elif s[0] == 255:
|
||||
|
|
Loading…
Reference in New Issue
Block a user