Corrected loadImageSeries type hint by radarhere · Pull Request #8624 · python-pillow/Pillow
Conversation
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 |
convert2byte()is a SpiderImageFile method, so the image must be a SPIDER image to call thatconvert2byte()returns anImageinstance, meaning thatloadImageSeriesreturns a list ofImages, notSpiderImageFiles.
| def convert2byte(self, depth: int = 255) -> Image.Image: |
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