Allowed ImageSequence to seek to zero

This commit is contained in:
Andrew Murray 2016-01-27 14:04:05 +11:00
parent 3d6e137ff2
commit 2b0c037d5f
2 changed files with 12 additions and 2 deletions

View File

@ -35,8 +35,7 @@ class Iterator(object):
def __getitem__(self, ix): def __getitem__(self, ix):
try: try:
if ix: self.im.seek(ix)
self.im.seek(ix)
return self.im return self.im
except EOFError: except EOFError:
raise IndexError # end of sequence raise IndexError # end of sequence

View File

@ -44,6 +44,17 @@ class TestImageSequence(PillowTestCase):
self._test_multipage_tiff() self._test_multipage_tiff()
TiffImagePlugin.READ_LIBTIFF = False TiffImagePlugin.READ_LIBTIFF = False
def test_consecutive(self):
im = Image.open('Tests/images/multipage.tiff')
firstFrame = None
for frame in ImageSequence.Iterator(im):
if firstFrame == None:
firstFrame = frame.copy()
pass
for frame in ImageSequence.Iterator(im):
self.assert_image_equal(frame, firstFrame)
break
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()