mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-22 13:14:45 +03:00
GIF: Fix the previous frame not always being decoded in _seek.
_seek checked whether self.im is None, but if we've decoded a frame and then seeked back to 0, self.im will be set to the previously decoded frame. Instead, check if self.tile has data, which means _seek set up a tile to decode and it hasn't been decoded yet.
This commit is contained in:
parent
b5806c7e15
commit
87e54b47ab
BIN
Tests/images/rewind.gif
Normal file
BIN
Tests/images/rewind.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 B |
|
@ -293,6 +293,26 @@ class TestFileGif(PillowTestCase):
|
|||
self.assertEqual(color, expected_colors[frame][x],
|
||||
'frame %i, x %i' % (frame, x))
|
||||
|
||||
def test_rewind(self):
|
||||
img = Image.open("Tests/images/rewind.gif")
|
||||
|
||||
# Seek forwards to frame 2. This will decode frames 0 and 1.
|
||||
img.seek(2)
|
||||
|
||||
# Seek back to frame 1. This will rewind to frame 0, then seek
|
||||
# to frame 1.
|
||||
img.seek(1)
|
||||
|
||||
# Read data. This should decode frame 0 and then frame 1.
|
||||
img.getpixel((0,1))
|
||||
|
||||
expected_colors = [(2, 3), (3, 1)]
|
||||
for x in range(2):
|
||||
for y in range(2):
|
||||
color = img.getpixel((x,y))
|
||||
self.assertEqual(color, expected_colors[x][y],
|
||||
'%ix%i' % (x, y))
|
||||
|
||||
def test_dispose_previous(self):
|
||||
img = Image.open("Tests/images/dispose_prev.gif")
|
||||
try:
|
||||
|
|
|
@ -144,7 +144,7 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
self.disposal_method = 0
|
||||
else:
|
||||
# ensure that the previous frame was loaded
|
||||
if not self.im:
|
||||
if self.tile:
|
||||
self.load()
|
||||
|
||||
if frame != self.__frame + 1:
|
||||
|
|
Loading…
Reference in New Issue
Block a user