SpiderImagePlugin: raise an error when seeking in a non-stack file

Using ImageSequence.Iterator on a non-stack SPIDER image leads to infinite loop.
EOFError (which stops the iteration) is never raised because when the image isn't a stack,
seek() returns gently without error.
This commit is contained in:
Jonathan Michalon 2016-02-23 14:08:39 +01:00 committed by Andrew Murray
parent fd7fa4e61d
commit d07ab52c66

View File

@ -173,7 +173,7 @@ class SpiderImageFile(ImageFile.ImageFile):
def seek(self, frame):
if self.istack == 0:
return
raise EOFError("attempt to seek in a non-stack file")
if frame >= self._nimages:
raise EOFError("attempt to seek past end of file")
self.stkoffset = self.hdrlen + frame * (self.hdrlen + self.imgbytes)