o �J�h��@sDddlmZddlmZddlmZGdd�d�Z dddd�ZdS)�)� annotations)�Callable�)�Imagec@s8eZdZdZddd�Zdd d �Zdd d �Zddd�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. �im� Image.Image�return�NonecCs0t|d�s d}t|��||_t|jdd�|_dS)N�seekzim must have seek methodZ _min_framer)�hasattr�AttributeErrorr�getattr�position)�selfr�msg�r�OC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\PIL\ImageSequence.py�__init__$s zIterator.__init__�ix�intc Cs<z |j�|�|jWSty}zd}t|�|�d}~ww)N�end of sequence)rr �EOFError� IndexError)rr�errrr� __getitem__+s  ��zIterator.__getitem__cCs|S�Nr)rrrr�__iter__3szIterator.__iter__c CsLz|j�|j�|jd7_|jWSty%}zd}t|�|�d}~ww)Nrr)rr rr� StopIteration)rrrrrr�__next__6s ��zIterator.__next__N)rrr r )rrr r)r r)r r)�__name__� __module__� __qualname__�__doc__rrrrrrrrrs   rNr�Image.Image | list[Image.Image]�func�+Callable[[Image.Image], Image.Image] | Noner �list[Image.Image]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� <listcomp>S�zall_frames.<locals>.<listcomp>csg|]}�|��qSrr)r)r�r%rrr*Vr+)� isinstance�list�tellrr )rr%�imsZ imSequence�currentrr,r� all_frames@s  r2r)rr$r%r&r r')� __future__r�typingr�rrr2rrrr�<module>s   *�
Memory