Use _min_frame in ImageSequence.Iterator

This commit is contained in:
Andrew Murray 2019-06-12 20:11:51 +10:00
parent 72d5ee3bfa
commit ea02e28adb
2 changed files with 7 additions and 1 deletions

View File

@ -32,6 +32,12 @@ class TestImageSequence(PillowTestCase):
self.assertRaises(IndexError, lambda: i[index+1])
self.assertRaises(StopIteration, next, i)
def test_iterator_min_frame(self):
im = Image.open('Tests/images/hopper.psd')
i = ImageSequence.Iterator(im)
for index in range(1, im.n_frames):
self.assertEqual(i[index], next(i))
def _test_multipage_tiff(self):
im = Image.open('Tests/images/multipage.tiff')
for index, frame in enumerate(ImageSequence.Iterator(im)):

View File

@ -32,7 +32,7 @@ class Iterator(object):
if not hasattr(im, "seek"):
raise AttributeError("im must have seek method")
self.im = im
self.position = 0
self.position = getattr(self.im, "_min_frame", 0)
def __getitem__(self, ix):
try: