Skip to content

Commit

Permalink
Merge pull request python-pillow#1686 from radarhere/seek
Browse files Browse the repository at this point in the history
Allow ImageSequence to seek to zero
  • Loading branch information
wiredfool committed Jan 31, 2016
2 parents 3f1834a + 2b0c037 commit 7d1df35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions PIL/ImageSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def __init__(self, im):

def __getitem__(self, ix):
try:
if ix:
self.im.seek(ix)
self.im.seek(ix)
return self.im
except EOFError:
raise IndexError # end of sequence
Expand Down
11 changes: 11 additions & 0 deletions Tests/test_imagesequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ def test_libtiff(self):
self._test_multipage_tiff()
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__':
unittest.main()

Expand Down

0 comments on commit 7d1df35

Please sign in to comment.