K iZddlmZddlmZdZerddlmZGddZ d d d Zy) ) annotations)ImageF)Callablec0eZdZdZddZddZd dZd dZy) Iteratora- This class implements an iterator object that can be used to loop over an image sequence. You can use the ``[]`` operator to access elements by index. This operator will raise an :py:exc:`IndexError` if you try to access a nonexistent frame. :param im: An image object. c|t|ds d}t|||_t|jdd|_y)Nseekzim must have seek method _min_framer)hasattrAttributeErrorimgetattrposition)selfrmsgs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/PIL/ImageSequence.py__init__zIterator.__init__&s7r6",C % %q9 c |jj||jS#t$r}d}t||d}~wwxYw)Nend of sequence)rr EOFError IndexError)rixers r __getitem__zIterator.__getitem__-sA ) GGLL 77N )#CS/q ( )s&) AAAc|SN)rs r__iter__zIterator.__iter__5s rc |jj|j|xjdz c_|jS#t$r}d}t ||d}~wwxYw)Nrr)rr rr StopIteration)rrrs r__next__zIterator.__next__8sT , GGLL ' MMQ M77N ,#C$! + ,sAA A$AA$N)r Image.ImagereturnNone)rintr%r$)r%r)r%r$)__name__ __module__ __qualname____doc__rrr r#rrrrrs :),rrNct|ts|g}g}|D]M}|j}|t|Dcgc]}|j c}z }|j |O|r|Dcgc] }|| c}S|Scc}wcc}w)a Applies a given function to all frames in an image or a list of images. The frames are returned as a list of separate images. :param im: An image, or a list of images. :param func: The function to apply to all of the image frames. :returns: A list of images. ) isinstancelisttellrcopyr )rfuncims imSequencecurrentim_frames r all_framesr6Bs b$ T C! //# 0DEH EE ! (,s #DH #44F $s B.Br)rzImage.Image | list[Image.Image]r1z+Callable[[Image.Image], Image.Image] | Noner%zlist[Image.Image]) __future__rr TYPE_CHECKINGcollections.abcrrr6rrrr;sG"# (%,%,T9=5'5 555r