Sindbad~EG File Manager
�
&ٜg� � �R � d dl mZ d dlmZ ddlmZ G d� d� Z d d
d�Zy)� )�annotations)�Callable� )�Imagec �0 � e Zd ZdZdd�Zdd�Zd d�Zd
d�Zy)�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 |d� s
d}t |� �|| _ t | j dd� | _ y )N�seekzim must have seek method�
_min_framer )�hasattr�AttributeError�im�getattr�position)�selfr �msgs �</usr/local/lib/python3.12/site-packages/PIL/ImageSequence.py�__init__zIterator.__init__$ s7 � ��r�6�"�,�C� ��%�%���������q�9��
� c � � | j j |� | j S # t $ r}d}t |� |�d }~ww xY w)N�end of sequence)r r
�EOFError�
IndexError)r �ix�er s r �__getitem__zIterator.__getitem__+ sA � � )��G�G�L�L����7�7�N��� )�#�C��S�/�q�(�� )�s �&) � A�A � Ac � � | S �N� )r s r �__iter__zIterator.__iter__3 s � ��r c �� � | j j | j � | xj dz
c_ | j S # t $ r}d}t |� |�d }~ww xY w)Nr r )r r
r r �
StopIteration)r r r s r �__next__zIterator.__next__6 sT � � ,��G�G�L�L����'��M�M�Q��M��7�7�N��� ,�#�C���$�!�+�� ,�s �AA � A$�A�A$N)r �Image.Image�return�None)r �intr% r$ )r% r )r% r$ )�__name__�
__module__�__qualname__�__doc__r r r r# r r r r r s � � �:�)��,r r Nc � � t | t � s| g} g }| D ]M }|j � }|t |� D �cg c] }|j � �� c}z
}|j |� �O |r|D � cg c]
} || � �� c} S |S c c}w c c} 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.
)�
isinstance�list�tellr �copyr
)r �func�ims�
imSequence�current�im_frames r �
all_framesr6 @ s� � � �b�$���T��
�C��
��/�/�#�����0D�E�0D�H��
�
��0D�E�E������ � � (,�s�#�s��D��H�s�#�4��4�� F�� $s �B�.Br )r zImage.Image | list[Image.Image]r1 z+Callable[[Image.Image], Image.Image] | Noner% zlist[Image.Image])�
__future__r �typingr � r r r6 r r r �<module>r: s? ��"