This should be relatively easy, but who knows...
Is there a way to retrieve the number of frames in a multi-page TIFF file using PIL/Pillow, without iterating through the whole stack until seek raises an error?
Try using n_frames:
from PIL import Image
tiffstack = Image.open('my_img.tiff')
tiffstack.load()
print(tiffstack.n_frames)
来源:https://stackoverflow.com/questions/26660415/pillow-and-multi-page-tiffs