diff --git a/PIL/ImageSequence.py b/PIL/ImageSequence.py index 256bcbedb..a979b8865 100644 --- a/PIL/ImageSequence.py +++ b/PIL/ImageSequence.py @@ -35,8 +35,7 @@ class Iterator(object): 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 diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index 9e18192ee..5429c2845 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -44,6 +44,17 @@ class TestImageSequence(PillowTestCase): 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()