a :jg˜ã@sJddlmZddlmZddlmZGdd„dƒZddd d d œd d „ZdS)é)Ú annotations)ÚCallableé)ÚImagec@sLeZdZdZdddœdd„Zdddœd d „Zdd œd d „Zdd œdd„ZdS)Ú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. z Image.ImageÚNone)ÚimÚreturncCs0t|dƒsd}t|ƒ‚||_t|jddƒ|_dS)NÚseekzim must have seek methodZ _min_framer)ÚhasattrÚAttributeErrorrÚgetattrÚposition)ÚselfrÚmsg©rú;/usr/local/lib/python3.9/site-packages/PIL/ImageSequence.pyÚ__init__$s  zIterator.__init__Úint)Úixr c CsLz|j |¡|jWStyF}zd}t|ƒ|‚WYd}~n d}~00dS)Núend of sequence)rr ÚEOFErrorÚ IndexError)rrÚerrrrÚ __getitem__+s  zIterator.__getitem__)r cCs|S)Nr)rrrrÚ__iter__3szIterator.__iter__c Cs\z$|j |j¡|jd7_|jWStyV}zd}t|ƒ|‚WYd}~n d}~00dS)Nrr)rr rrÚ StopIteration)rrrrrrÚ__next__6szIterator.__next__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrrrs  rNzImage.Image | list[Image.Image]z+Callable[[Image.Image], Image.Image] | Nonezlist[Image.Image])rÚfuncr cs`t|tƒs|g}g}|D],}| ¡}|dd„t|ƒDƒ7}| |¡qˆr\‡fdd„|DƒS|S)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. cSsg|] }| ¡‘qSr)Úcopy)Ú.0Zim_framerrrÚ Sózall_frames..csg|] }ˆ|ƒ‘qSrr)r$r©r"rrr%Vr&)Ú isinstanceÚlistÚtellrr )rr"ZimsZ imSequenceÚcurrentrr'rÚ all_frames@s  r,)N)Ú __future__rÚtypingrÚrrr,rrrrÚs   *þ