Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Corrected loadImageSeries type hint #8624

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

radarhere
Copy link
Member

This is part of #8362 - I'm hoping to break down that PR into easier-to-review chunks.

Two changes to loadImageSeries.

def loadImageSeries(filelist: list[str] | None = None) -> list[SpiderImageFile] | None:
"""create a list of :py:class:`~PIL.Image.Image` objects for use in a montage"""
if filelist is None or len(filelist) < 1:
return None
imglist = []
for img in filelist:
if not os.path.exists(img):
print(f"unable to find {img}")
continue
try:
with Image.open(img) as im:
im = im.convert2byte()
except Exception:
if not isSpiderImage(img):
print(f"{img} is not a Spider image file")
continue
im.info["filename"] = img
imglist.append(im)
return imglist

  1. convert2byte() is a SpiderImageFile method, so the image must be a SPIDER image to call that
  2. convert2byte() returns an Image instance, meaning that loadImageSeries returns a list of Images, not SpiderImageFiles.

def convert2byte(self, depth: int = 255) -> Image.Image:

@hugovk hugovk merged commit f9767fb into python-pillow:main Dec 26, 2024
49 checks passed
@radarhere radarhere deleted the type_hint_spider branch December 26, 2024 23:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants