
     f                    P    d dl mZ d dlmZ ddlmZ  G d d          Z	 dddZdS )    )annotations)Callable   )Imagec                  2    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.
    imImage.Imagec                    t          |d          sd}t          |          || _        t          | j        dd          | _        d S )Nseekzim must have seek method
_min_framer   )hasattrAttributeErrorr	   getattrposition)selfr	   msgs      T/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/PIL/ImageSequence.py__init__zIterator.__init__$   sG    r6"" 	&,C %%%q99    ixintreturnc                    	 | j                             |           | j         S # t          $ r}d}t          |          |d }~ww xY w)Nend of sequence)r	   r   EOFError
IndexError)r   r   er   s       r   __getitem__zIterator.__getitem__+   sT    	)GLL7N 	) 	) 	)#CS//q(	)s    # 
A?Ac                    | S N )r   s    r   __iter__zIterator.__iter__3   s    r   c                    	 | j                             | j                   | xj        dz  c_        | j         S # t          $ r}d}t	          |          |d }~ww xY w)Nr   r   )r	   r   r   r   StopIteration)r   r   r   s      r   __next__zIterator.__next__6   sh    	,GLL'''MMQMM7N 	, 	, 	,#C$$!+	,s   58 
AAAN)r	   r
   )r   r   r   r
   )r   r   )r   r
   )__name__
__module____qualname____doc__r   r   r#   r&   r"   r   r   r   r      sn        	 	: : : :) ) ) )   , , , , , ,r   r   Nr	   Image.Image | list[Image.Image]func+Callable[[Image.Image], Image.Image] | Noner   list[Image.Image]c                    t          | t                    s| g} g }| D ]G}|                                }|d t          |          D             z  }|                    |           Hrfd|D             n|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                6    g | ]}|                                 S r"   )copy).0im_frames     r   
<listcomp>zall_frames.<locals>.<listcomp>S   s     EEEHEEEr   c                &    g | ]} |          S r"   r"   )r2   r	   r,   s     r   r4   zall_frames.<locals>.<listcomp>V   s!    ###DDHH###r   )
isinstancelisttellr   r   )r	   r,   ims
imSequencecurrents    `   r   
all_framesr<   @   s     b$ T
C ! !
//##EE0D0DEEEE    '+4####s####4r   r!   )r	   r+   r,   r-   r   r.   )
__future__r   typingr    r   r   r<   r"   r   r   <module>r@      s   " # " " " " "            %, %, %, %, %, %, %, %,T 9=5 5 5 5 5 5 5r   