o
    gP                     @   s   G d d dZ dddZdS )c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )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                 C   s0   t |dsd}t||| _t| jdd| _d S )Nseekzim must have seek method
_min_frame    )hasattrAttributeErrorimgetattrposition)selfr   msg r   O/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/PIL/ImageSequence.py__init__   s
   
zIterator.__init__c              
   C   s4   z
| j | | j W S  ty } zt|d }~ww N)r   r   EOFError
IndexError)r
   ixer   r   r   __getitem__&   s   zIterator.__getitem__c                 C   s   | S r   r   )r
   r   r   r   __iter__-   s   zIterator.__iter__c              
   C   sD   z| j | j |  jd7  _| j W S  ty! } zt|d }~ww )N   )r   r   r	   r   StopIteration)r
   r   r   r   r   __next__0   s   zIterator.__next__N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r      s    r   Nc                    s`   t | ts| g} g }| D ]}| }|dd t|D 7 }|| q r. fdd|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.
    c                 S   s   g | ]}|  qS r   )copy).0im_framer   r   r   
<listcomp>I       zall_frames.<locals>.<listcomp>c                    s   g | ]} |qS r   r   )r   r   funcr   r   r    L   r!   )
isinstancelisttellr   r   )r   r#   ims
imSequencecurrentr   r"   r   
all_frames9   s   
	r*   r   )r   r*   r   r   r   r   <module>   s   &