Skip to content

Count SPIDER frames, instead of using imgnumber for position - #10680

Merged
radarhere merged 2 commits into
python-pillow:mainfrom
radarhere:spider_seek
Dec 1, 2026
Merged

radarhere merged 2 commits into
python-pillow:mainfrom
radarhere:spider_seek

Conversation

@radarhere

Copy link
Copy Markdown
Member

At the moment, SPIDER reports its frame number based on imgnumber.

self.imgnumber = int(h[27])

def tell(self) -> int:
if self.imgnumber < 1:
return 0
else:
return self.imgnumber - 1

However, https://web.archive.org/web/20201104112530/https://spider.wadsworth.org/spider_doc/spider/docs/image_doc.html says

27 | IMGNUM | Position is only used in a stacked image header. There, this position contains the number of the current image or zero if this image is unused.

which indicates that after seek()ing forward to a particular frame, tell() might report zero. That's not helpful.

Let's report the frame that the user requested instead. imgnumber will still be a property on the image instance if the user would like that information.

@radarhere
radarhere merged commit 1aceb09 into python-pillow:main Dec 1, 2026
56 checks passed
@radarhere
radarhere deleted the spider_seek branch December 1, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant