FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Corrected loadImageSeries type hint by radarhere · Pull Request #8624 · python-pillow/Pillow · GitHub

Corrected loadImageSeries type hint - #8624

Merged
hugovk merged 1 commit into
python-pillow:mainfrom
radarhere:type_hint_spider
Dec 26, 2024
Merged

Corrected loadImageSeries type hint#8624
hugovk merged 1 commit into
python-pillow:mainfrom
radarhere:type_hint_spider

Conversation

Copy link
Copy Markdown
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 merged commit f9767fb into python-pillow:main Dec 26, 2024
radarhere deleted the type_hint_spider branch December 26, 2024 23:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL