%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/PIL/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/PIL/__pycache__/PngImagePlugin.cpython-312.pyc

�

��e������ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZmZddlmZddlmZddlmZdd	lmZdd
lmZej4e�Zej:d�j<ZdZ d
ddddddddddddddd�Z!ej:d�Z"e
jFZ$	de$zZ%	Gd�d e	�Z&Gd!�d"e	�Z'd#�Z(dKd$�Z)Gd%�d&�Z*Gd'�d(e+�Z,Gd)�d*�Z-Gd+�d,e*�Z.d-�Z/Gd.�d/e
j�Z0d0d1d2d3d4d5d6d6d6d7d8d9d:d;d<d=�Z1d>�Z2Gd?�d@�Z3GdA�dB�Z4dC�Z5dD�Z6e2dEfdF�Z7dG�Z8ejre0jte0e/�ejve0jte7�ejxe0jte6�ejze0jtdHdIg�ej|e0jtdJ�y)L�)�annotationsN)�IntEnum�)�Image�
ImageChops�	ImageFile�ImagePalette�
ImageSequence)�i16be)�i32be)�o8)�o16be)�o32bes\w\w\w\ws�PNG

)�1r)�L�L;2)r�L;4)rr)�I�I;16B)�RGBr)rzRGB;16B)�P�P;1)r�P;2)r�P;4)rr)�LAr)�RGBAzLA;16B)rr)rzRGBA;16B))rr)�r)�r)�r)�r)rr)r r)r�)rr!)rr!)rr!)rr)r r)r�)r r"s^�*�*$�@c��eZdZdZ	dZ	dZy)�DisposalrrrN)�__name__�
__module__�__qualname__�OP_NONE�
OP_BACKGROUND�OP_PREVIOUS���4/usr/lib/python3/dist-packages/PIL/PngImagePlugin.pyr%r%cs$���G���M��
�K�r-r%c��eZdZdZ	dZy)�BlendrrN)r&r'r(�	OP_SOURCE�OP_OVERr,r-r.r0r0xs���I��
�G�r-r0c��tj�}|j|t�}|jr
d}t|��|S)NzDecompressed Data Too Large)�zlib�
decompressobj�
decompress�MAX_TEXT_CHUNK�unconsumed_tail�
ValueError)�s�dobj�	plaintext�msgs    r.�_safe_zlib_decompressr>�s>������D�����>�2�I����+����o���r-c�4�tj||�dzS)Nl��)r4�crc32)�data�seeds  r.�_crc32rC�s���:�:�d�D�!�J�.�.r-c�J�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd
�Zy)
�ChunkStreamc� �||_g|_y�N)�fp�queue)�selfrHs  r.�__init__zChunkStream.__init__�s�������
r-c��d}|jr:|jj�\}}}|jj|�nE|jj	d�}|dd}|jj�}t
|�}t|�s*tjsdt|��d�}t|��|||fS)z.Fetch a new chunk. Returns header information.Nrrzbroken PNG file (chunk �))rI�poprH�seek�read�tell�i32�is_cidr�LOAD_TRUNCATED_IMAGES�repr�SyntaxError)rJ�cid�pos�lengthr:r=s      r.rPzChunkStream.read�s������:�:�#�z�z�~�~�/��C��f��G�G�L�L��������Q��A��A�B�%�C��'�'�,�,�.�C���V�F��c�{��2�2�/��S�	�{�!�<��!�#�&�&��C���r-c��|SrGr,�rJs r.�	__enter__zChunkStream.__enter__�s���r-c�$�|j�yrG)�close)rJ�argss  r.�__exit__zChunkStream.__exit__�s���
�
�r-c� �dx|_|_yrG)rIrHr[s r.r^zChunkStream.close�s��#�#��
�T�Wr-c�@�|jj|||f�yrG)rI�append�rJrWrXrYs    r.�pushzChunkStream.push�s���
�
���3��V�,�-r-c�|�tjd|||�t|d|jd�z�||�S)z"Call the appropriate chunk handlerzSTREAM %r %s %s�chunk_�ascii)�logger�debug�getattr�decoderds    r.�callzChunkStream.call�s;��	���&��S�&�9�<�w�t�X��
�
�7�(;�;�<�S�&�I�Ir-c�~�tjr|ddz	dzr|j||�y	t|t|��}t	|j
j
d��}||k7rdt|��d�}t|��y#tj$r }dt|��d�}t|�|�d}~wwxYw)	zRead and verify checksumr�rNrz(broken PNG file (bad header checksum in rMz(broken PNG file (incomplete checksum in )rrT�crc_skiprCrRrHrPrUrV�struct�error)rJrWrA�crc1�crc2r=�es       r.�crczChunkStream.crc�s����*�*��A��!��a���M�M�#�t�$��	*��$��s��,�D��t�w�w�|�|�A��'�D��t�|�@��c���1�M��!�#�&�&����|�|�	*�<�T�#�Y�K�q�I�C��c�"��)��	*�s�AB	�	B<�B7�7B<c�:�|jjd�y)z
Read checksumrN)rHrP)rJrWrAs   r.rpzChunkStream.crc_skip�s��	
�����Q�r-c��g}		|j�\}}}||k(r	|S|j	|tj|j|��|j|��_#tj$r}d}t|�|�d}~wwxYw)Nztruncated PNG file)	rPrqrr�OSErrorrvr�
_safe_readrHrc)rJ�endchunk�cidsrWrXrYrur=s        r.�verifyzChunkStream.verify�s������
*�#'�9�9�;� ��S�&�
�h�����
�H�H�S�)�.�.�t�w�w��?�@��K�K������<�<�
*�*���c�l��)��
*�s�A#�#B	�6B�B	N)�IEND)
r&r'r(rKrPr\r`r^rermrvrpr}r,r-r.rErE�s5��� �(��$�.�J�*�(�
r-rEc�"�eZdZdZedd��Zy)�iTXtzq
    Subclass of string to allow iTXt chunks to look like strings while
    keeping their extra information

    Nc�N�tj||�}||_||_|S)z�
        :param cls: the class to use when creating the instance
        :param text: value for this key
        :param lang: language code
        :param tkey: UTF-8 version of the key name
        )�str�__new__�lang�tkey)�cls�textr�r�rJs     r.r�ziTXt.__new__�s'���{�{�3��%����	���	��r-)NN)r&r'r(�__doc__�staticmethodr�r,r-r.r�r��s������r-r�c�.�eZdZdZd�Zdd�Zdd�Zdd�Zy)	�PngInfoz<
    PNG chunk container (for use with save(pnginfo=))

    c��g|_yrG)�chunksr[s r.rKzPngInfo.__init__s	����r-c�z�||g}|r|jd�|jjt|��y)a"Appends an arbitrary chunk. Use with caution.

        :param cid: a byte string, 4 bytes long.
        :param data: a byte string of the encoded data
        :param after_idat: for use with private chunks. Whether the chunk
                           should be written after IDAT

        TN)rcr��tuple)rJrWrA�
after_idat�chunks     r.�addzPngInfo.adds2���d�����L�L��������5��<�(r-c���t|t�s|jdd�}t|t�s|jdd�}t|t�s|jdd�}t|t�s|jdd�}|r8|jd|dz|zdz|zdzt	j
|�z�y|jd|dz|zdz|zdz|z�y)	z�Appends an iTXt chunk.

        :param key: latin-1 encodable text key name
        :param value: value for this key
        :param lang: language code
        :param tkey: UTF-8 version of the key name
        :param zip: compression flag

        �latin-1�strict�utf-8�iTXts�sN)�
isinstance�bytes�encoder�r4�compress)rJ�key�valuer�r��zips      r.�add_itxtzPngInfo.add_itxts����#�u�%��*�*�Y��1�C��%��'��L�L��(�3�E��$��&��;�;�w��1�D��$��&��;�;�w��1�D���H�H���k�!�D�(�5�0�4�7�%�?�$�-�-�PU�BV�V�
�

�H�H�W�c�I�o��4�u�<�t�C�e�K�e�S�Tr-c���t|t�r*|j|||j|j|��St|t
�s	|j
dd�}t|t
�s|j
dd�}|r,|jd|dztj|�z�y|jd|dz|z�y#t$r|j|||��cYSwxYw)	z�Appends a text chunk.

        :param key: latin-1 encodable text key name
        :param value: value for this key, text or an
           :py:class:`PIL.PngImagePlugin.iTXt` instance
        :param zip: compression flag

        )r�r�r��zTXt��tEXtr�N)r�r�r�r�r�r�r��UnicodeErrorr�r4r�)rJr�r�r�s    r.�add_textzPngInfo.add_text:s����e�T�"��=�=��e�U�Z�Z�����=�M�M��%��'�
:����Y��9���#�u�%��*�*�Y��1�C���H�H�W�c�G�m�d�m�m�E�.B�B�C��H�H�W�c�E�k�E�1�2�� �
:��}�}�S�%�S�}�9�9�
:�s�C�C'�&C'N�F)�r�F)r&r'r(r�rKr�r�r�r,r-r.r�r�s���
�
)�U�83r-r�c���eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�	PngStreamc���t�|�|�i|_i|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_y)N�rrr)
�superrK�im_info�im_text�im_size�im_mode�im_tile�
im_palette�im_custom_mimetype�im_n_frames�_seq_num�rewind_state�text_memory)rJrH�	__class__s  �r.rKzPngStream.__init__[sc���
�����������������������"&��������
� �����r-c��|xj|z
c_|jtkDrd|j�d�}t|��y)Nz%Too much memory used in text chunks: z>MAX_TEXT_MEMORY)r��MAX_TEXT_MEMORYr9)rJ�chunklenr=s   r.�check_text_memoryzPngStream.check_text_memorylsN�����H�$�����o�-�7��#�#�$�$4�6�
��S�/�!�.r-c�r�|jj�|j|jd�|_y)N)�info�tile�seq_num)r��copyr�r�r�r[s r.�save_rewindzPngStream.save_rewindus*���L�L�%�%�'��L�L��}�}�
��r-c�|�|jd|_|jd|_|jd|_y)Nr�r�r�)r�r�r�r�r[s r.�rewindzPngStream.rewind|s8���(�(��0����(�(��0����)�)�)�4��
r-c��tj|j|�}|jd�}tjd|d|�tjd||�||}|dk7rd|�d�}t
|��	t||dzd�}||jd<|S#t$rtjrd}n�Y�0tj$rd}Y�FwxYw)	Nr�ziCCP profile name %rzCompression method %sr�Unknown compression method z in iCCP chunkr�icc_profile)
rrzrH�findrirjrVr>r9rTr4rrr�)rJrXrYr:�i�comp_methodr=r�s        r.�
chunk_iCCPzPngStream.chunk_iCCP�s���� � ����&�1��
�F�F�5�M�����+�Q�r��U�3����,�a��d�3���d���!��/��}�N�K�C��c�"�"�	�/��!�a�%�'�
�;�K�'2����]�#�����	��.�.�"�����z�z�	��K�	�s�B"�"C�C�Cc�p�tj|j|�}|dkrtjr|Sd}t	|��t|d�t|d�f|_	t|d|df\|_|_	|drd|jd	<|d
r
d}t|��|S#t$rY�3wxYw)N�
zTruncated IHDR chunkrrr�	�r�	interlace�zunknown filter category)
rrzrHrTr9rRr��_MODESr��
im_rawmode�	Exceptionr�rV�rJrXrYr:r=s     r.�
chunk_IHDRzPngStream.chunk_IHDR�s���� � ����&�1���B�;��.�.���(�C��S�/�!��1�a�y�#�a��)�+���	�,2�A�a�D�!�A�$�<�,@�)�D�L�$�/�
�R�5�()�D�L�L��%��R�5�+�C��c�"�"�����	��	�s�#B)�)	B5�4B5c��d|jvrd|jd||jfg}n9|j�d|jd<dd|jz||jfg}||_||_d}t
|��)N�bboxr�T�
default_imager�zimage data found)r�r�r�r�r��im_idat�EOFError)rJrXrYr�r=s     r.�
chunk_IDATzPngStream.chunk_IDAT�s����T�\�\�!��D�L�L��0�#�t���G�H�D����+�04����_�-��F�T�\�\�1�3����H�I�D������� ���s�m�r-c��d}t|��)Nzend of PNG image)r�)rJrXrYr=s    r.�
chunk_IENDzPngStream.chunk_IEND�s�� ���s�m�r-c�v�tj|j|�}|jdk(r	d|f|_|S)Nrr)rrzrHr�r��rJrXrYr:s    r.�
chunk_PLTEzPngStream.chunk_PLTE�s4��� � ����&�1���<�<�3��#�Q�h�D�O��r-c���tj|j|�}|jdk(rMtj|�r'|j
d�}|dk\r ||jd<|S||jd<|S|jdvrt|�|jd<|S|jdk(r/t|�t|d�t|d�f|jd<|S)	Nrr�r�transparency�rrrrrr)	rrzrHr��_simple_palette�matchr�r��i16)rJrXrYr:r�s     r.�
chunk_tRNSzPngStream.chunk_tRNS�s���� � ����&�1���<�<�3���$�$�Q�'��F�F�5�M����6�34�D�L�L��0���01����^�,�
��	�\�\�_�
,�+.�q�6�D�L�L��(����\�\�U�
"�+.�q�6�3�q�!�9�c�!�Q�i�+G�D�L�L��(��r-c�|�tj|j|�}t|�dz|jd<|S)N�j�@�gamma)rrzrHrRr�r�s    r.�
chunk_gAMAzPngStream.chunk_gAMA�s4��� � ����&�1�� #�A��� 1����W���r-c���tj|j|�}tjdt|�dzz|�}t
d�|D��|jd<|S)Nz>%dIrc3�&K�|]	}|dz���y�w)r�Nr,)�.0�elts  r.�	<genexpr>z'PngStream.chunk_cHRM.<locals>.<genexpr>�s����,P��S�8�^�,P�s��chromaticity)rrzrHrq�unpack�lenr�r�)rJrXrYr:�raw_valss     r.�
chunk_cHRMzPngStream.chunk_cHRM�sU��
� � ����&�1���=�=��3�q�6�Q�;�!7��;��',�,P�x�,P�'P����^�$��r-c��tj|j|�}|dkrtjr|Sd}t	|��|d|j
d<|S)NrzTruncated sRGB chunkr�srgb)rrzrHrTr9r�r�s     r.�
chunk_sRGBzPngStream.chunk_sRGB�sU��
� � ����&�1���A�:��.�.���(�C��S�/�!� ��t����V���r-c�4�tj|j|�}|dkrtjr|Sd}t	|��t|d�t|d�}}|d}|dk(r|dz|dzf}||jd<|S|dk(r||f|jd	<|S)
Nr�zTruncated pHYs chunkrrrr�
F%u�?�dpi�aspect)rrzrHrTr9rRr�)	rJrXrYr:r=�px�py�unitr�s	         r.�
chunk_pHYszPngStream.chunk_pHYs�s���� � ����&�1���A�:��.�.���(�C��S�/�!��Q���C��1�I�B����t���1�9��v�+�r�F�{�*�C�"%�D�L�L������Q�Y�%'��V�D�L�L��"��r-c�b�tj|j|�}	|jdd�\}}|rc|jdd�}|jdd�}|dk(r|n||j|<||j|<|jt|��|S#t$r|}d}Y�vwxYw)Nr�rr-r�r��replace�exif)
rrzrH�splitr9rlr�r�r�r�)rJrXrYr:�k�v�v_strs       r.�
chunk_tEXtzPngStream.chunk_tEXts���� � ����&�1��	��7�7�5�!�$�D�A�q�

�����H�-�A��H�H�Y�	�2�E�#$��;�a�E�D�L�L��O�#�D�L�L��O��"�"�3�u�:�.�����	��A��A�	�s�B�
B.�-B.c�$�tj|j|�}	|jdd�\}}|r|d}nd}|dk7rd|�d�}t|��	t
|dd�}|r\|jdd�}|jdd	�}|x|j|<|j|<|jt|��|S#t$r|}d}Y��wxYw#t$rtjrd}n�Y��tj$rd}Y��wxYw)
Nr�rr-rr�z in zTXt chunkr�r�r)rrzrHrr9rVr>rTr4rrrlr�r�r�r�)rJrXrYr:rrr�r=s        r.�
chunk_zTXtzPngStream.chunk_zTXts$��� � ����&�1��	��7�7�5�!�$�D�A�q�
��A�$�K��K��!��/��}�N�K�C��c�"�"�	�%�a���e�,�A�
�����H�-�A�����I�.�A�01�1�D�L�L��O�d�l�l�1�o��"�"�3�q�6�*����7�	��A��A�	���	��.�.������z�z�	��A�	�s)�C�C�
C�C�D�8D�Dc��tj|j|�x}}	|jdd�\}}t|�dkr|S|d|d|dd}}}	|jdd�\}}	}
|dk7r|dk(r
	t
|
�}
n|S	|jdd�}|jdd�}|	jdd�}	|
jdd�}
t|
||	�x|j|<|j|<|jt|
��|S#t$r|cYSwxYw#t$r|cYSwxYw#t$rtjr|cYS�tj$r|cYSwxYw#t$r|cYSwxYw)Nr�rrrr�r�r�)rrzrHrr9r�r>rTr4rrrlr�r�r�r�r�)rJrXrY�rr:r�cf�cmr��tkrs           r.�
chunk_iTXtzPngStream.chunk_iTXtAs����$�$�T�W�W�f�5�5��A�	��7�7�5�!�$�D�A�q��q�6�A�:��H��a�D�!�A�$��!�"���B��	��'�'�%��+�K�D�"�a���7��Q�w��-�a�0�A���	�����H�-�A��;�;�w��1�D����7�H�-�B�����(�+�A�-1��D�"�,=�=����Q��$�,�,�q�/����s�1�v�&����C�	��H�	���	��H�	��"�� �6�6� ����z�z���H����	��H�	�sN�D�D'�:D8�	AE0�D$�#D$�'D5�4D5�8E-�E-�,E-�0E>�=E>c�j�tj|j|�}d|z|jd<|S)N�Exifr)rrzrHr�r�s    r.�
chunk_eXIfzPngStream.chunk_eXIfis0��� � ����&�1��.��2����V���r-c��tj|j|�}|dkrtjr|Sd}t	|��|j
�d|_t
jd�|St|�}|dk(s|dkDrt
jd�|S||_t|d�|jd<d|_
|S)	Nrz"APNG contains truncated acTL chunkz4Invalid APNG, will use default PNG image if possiblerlr�loopz
image/apng)rrzrHrTr9r��warnings�warnrRr�r�)rJrXrYr:r=�n_framess      r.�
chunk_acTLzPngStream.chunk_acTLos���� � ����&�1���A�:��.�.���6�C��S�/�!����'�#�D���M�M�P�Q��H��q�6���q�=�H�z�1��M�M�P�Q��H�#���"�1�a�y����V��".����r-c���tj|j|�}|dkrtjr|Sd}t	|��t|�}|j�|dk7s|j�|j|dz
k7r
d}t|��||_t|d�t|d�}}t|d�t|d	�}	}|j\}
}||z|
kDs|	|z|kDr
d
}t|��||	||z|	|zf|jd<t|d�t|d
�}
}|
dk(rd}
t|�t|
�zdz|jd<|d|jd<|d|jd<|S)N�z"APNG contains truncated fcTL chunkrr�#APNG contains frame sequence errorsrrr�r zAPNG contains invalid framesr����d���duration��disposal��blend)rrzrHrTr9rRr�rVr�r�r��float)rJrXrYr:r=�seq�width�heightr�r�im_w�im_h�	delay_num�	delay_dens              r.�
chunk_fcTLzPngStream.chunk_fcTL�sn��� � ����&�1���B�;��.�.���6�C��S�/�!��!�f���M�M�!�c�Q�h��M�M�%�$�-�-�3��7�*B�7�C��c�"�"���
��A�q�	�3�q�!�9�v���Q���S��B�Z�B���\�\�
��d�
��:����V��d� 2�0�C��c�"�"� "�B��U�
�B��K�@����V��"�1�b�z�3�q�"�:�9�	���>��I�#(��#3�e�I�6F�#F��#M����Z� �#$�R�5����Z� � !�"�����W���r-c�\�|dkr?tjr"tj|j|�}|Sd}t	|��tj|jd�}t|�}|j|dz
k7r
d}t|��||_|j|dz|dz
�S)Nrz"APNG contains truncated fDAT chunkrr)	rrTrzrHr9rRr�rVr�)rJrXrYr:r=r)s      r.�
chunk_fdATzPngStream.chunk_fdAT�s����A�:��.�.��(�(����&�9����6�C��S�/�!�� � ����!�,���!�f���=�=�C�!�G�#�7�C��c�"�"���
����s�Q�w���
�3�3r-)r&r'r(rKr�r�r�r�r�r�r�r�r�r�r�r�rr
rrrrr0r2�
__classcell__�r�s@r.r�r�Zsn����""�
�5�
�6�(����(��� �"�& �D&�P��(�:
4r-r�c��|ddtk(S)Nr)�_MAGIC)�prefixs r.�_acceptr8�s���"�1�:���r-c�t��eZdZdZdZd�Zed��Zd�Zd�Z	dd�Z
d�Zd	�Zd
�Z
d�Zd�Z�fd
�Zd�Z�xZS)�PngImageFile�PNGzPortable network graphicsc�F�t|jjd��s
d}t|��|j|_d|_g|_t|j�|_	|jj�\}}}	|jj|||�}|jj%||��Y#t$rYnvt$rktjd|||�tj|j|�}|ddj!�r|jj#||f�Y��wxYw|jj&|_|jj*|_|jj.|_d|_|jj4|_|jj8|_|jj<xsd|_|j0jAdd�|_!|jjDr4|jjD\}}tGjH||�|_%|d	k(r|d
z
|_&n||_&|jj<��d|_'|jjQ�|jL|_)|jjU�|_+|jBr|xj>dz
c_|jYd�|j>dkD|_-y)Nrznot a PNG filer�%r %s %s (unknown)rrr�F�fdATr).r8rHrPrV�_fp�_PngImageFile__frame�private_chunksr��pngrmr��AttributeErrorrirjrrz�islowerrcrvr��_moder��_sizer�r��_textr�r�r��custom_mimetyper�r�getr�r�r	�raw�palette�_PngImageFile__prepare_idat�!_close_exclusive_fp_after_loadingr��_PngImageFile__rewind_idatrQ�_PngImageFile__rewind�_seek�is_animated)rJr=rWrXrYr:�rawmoderAs        r.�_openzPngImageFile._open�sf���t�w�w�|�|�A��'�"�C��c�"�"��7�7������
!����T�W�W�%���� $�x�x�}�}���C��f�
9��H�H�M�M�#�s�F�3��
�H�H�L�L��a� �!���
��!�
9����1�3��V�D��(�(����&�9���q��8�#�#�%��'�'�.�.��Q�x�8��	
9���X�X�%�%��
��X�X�%�%��
��H�H�$�$��	���
��H�H�$�$��	�#�x�x�:�:������,�,�1���
�!�Y�Y�]�]�?�E�B����8�8��� �H�H�/�/�M�G�T�'�+�+�G�T�:�D�L��'�>�"(�1�*�D��"(�D���8�8���+�5:�D�2��H�H� � �"�!%�!4�!4�D�� �H�H�M�M�O�D�M��!�!��
�
��"�
��J�J�q�M��=�=�1�,��s�C�	E�A0E�Ec��|j�c|jr*|j}|j|jdz
�|j�|jr|j�|jS)Nr)rGrQr@rOr�load)rJ�frames  r.r�zPngImageFile.texts_���:�:����������	�	�$�-�-�!�+�,��I�I�K�����	�	�%� ��z�z�r-c�T�|j�
d}t|��|jj|jdddz
�|jj�|jj
�|jr|jj
�d|_y)zVerify PNG fileNz)verify must be called directly after openrrr)rH�RuntimeErrorrOr�rBr}r^�
_exclusive_fp)rJr=s  r.r}zPngImageFile.verifysy���7�7�?�=�C��s�#�#�	
�����T�Y�Y�q�\�!�_�q�(�)�����������������G�G�M�M�O���r-c�H�|j|�sy||jkr|jdd�|j}t|jdz|dz�D]}	|j|��y#t$r$}|j|�d}t	|�|�d}~wwxYw)NrTrzno more images in APNG file)�_seek_checkr@rP�ranger�rO)rJrV�
last_frame�frur=s      r.rOzPngImageFile.seek#s�������&���4�<�<���J�J�q�$���\�\�
��t�|�|�a�'����3�	+�A�
+��
�
�1�
�	+���
+��	�	�*�%�3���s�m��*��
+�s� A4�4	B!�=B�B!c�^
�|dk(�rK|r�|jj|j�|jj	�|j
|_d|_|jrd|_|jj|_
|jj|_|j|_
d|_d|_|jj!dd�|_|jj!d�|_|jj!d�|_|jj!d�|_d|_�n_||j*dzk7rd|��}t-|��|j/�|jr0|jj1|j|j(�|jj3�|_|j|_
|jr1t5j6|j|j�d|_d}	|jj9d
�	|jj9�\}}}|dk(r
d}tA|��|d
k(r|r
d}t?|��d	}	|jjC|||���|j�2|j$tLjNk(rtLjP|_|j$tLjNk(rK|jj3�|_|jS|j|j(�|_y|j$tLjPk(retTjVjY|jZ|j\�|_|jS|j|j(�|_yd|_y#t:j<t>f$rYn�wxYw#tD$rYn�t@$r9|dk(r|d
z}|r	||_Ynjt5j6|j|�Y���tF$r<tHjKd|||�t5j6|j|�Y���wxYw||_|jj|_|jj!d�|_|jj!d�|_|jj!d�|_|jr��qd}tA|��)Nrr�Fr%r'r�rzcannot seek to frame Trr~zNo more images in APNG file�fcTLzAPNG missing frame datar>r=zimage not found in APNG frame)/r?rOrOrBr�rNrL�im�pyaccessr�r�r�r�rH�_prev_im�disposerIr��
dispose_op�blend_op�dispose_extentr@r9rU�paster�rrzrPrqrrrVr�rm�UnicodeDecodeErrorrCrirjr%r+r*�_cropr�core�fill�mode�size)rJrVr�r=�frame_startrWrXrYs        r.rPzPngImageFile._seek2s����A�:�����
�
�d�m�m�,������!�&*�&8�&8��#�����=�=�$(�D�M� �H�H�,�,��	� �H�H�,�,��	��(�(��� �D�M��D�L�!%�������!F�D��"�i�i�m�m�J�7�D�O� �I�I�M�M�'�2�D�M�"&�)�)�-�-��"7�D���D�L�����q�(�(�-�e�W�5�� ��o�%�
�I�I�K��|�|����
�
�d�l�l�D�,?�,?�@� �G�G�L�L�N�D�M��h�h�D�G��"�"��$�$�T�W�W�d�.A�.A�B�&'��#��K�������Q���'+�x�x�}�}��$�C��f��'�>�7�C�"�3�-�'��'�>�"�7��)�#�.�.�"&�K�
:��H�H�M�M�#�s�F�3�'�X�=�=� �T�_�_��8L�8L�%L�&�4�4�D�O��?�?�h�2�2�2��=�=�-�-�/�D�L��:�:�d�l�l�D�4G�4G�H�D�L�
�_�_�� 6� 6�
6� �:�:�?�?�4�9�9�d�i�i�@�D�L��:�:�d�l�l�D�4G�4G�H�D�L��D�L��c���k�2�����*����:��g�~��!���&�28�D�/�!��(�(����&�9�%�:��L�L�!5�s�C��H��(�(����&�9�:��!�D�L����(�(�D�I�"�i�i�m�m�J�7�D�O� �I�I�M�M�'�2�D�M�"&�)�)�-�-��"7�D���9�9�5���s�m�#s7�O!�P�!O=�<O=�	R�R�( R�AR�Rc��|jSrG)r@r[s r.rQzPngImageFile.tell�s���|�|�r-c���|jjd�r|jdz|_|j|_t
j
j
|�y)z"internal: prepare to read PNG filer�)rN)r�rI�
decoderconfigrL�_PngImageFile__idatr�load_preparer[s r.rtzPngImageFile.load_prepare�sH���9�9�=�=��%�!%�!3�!3�d�!:�D���)�)������(�(��.r-c�,�|jdk(r�|jjd�|jj�\}}}|dvr|jj	|||�y|dk(r)	|jj|||�|dz
|_n||_|jdk(r��|dkr
|j}nt||j�}|j|z
|_|jj|�S#t$rY��wxYw)zinternal: read more image datarr)�IDATsDDATr>r-r>)rsrHrPrBrermr��min)rJ�
read_bytesrWrXrYs     r.�	load_readzPngImageFile.load_read�s����k�k�Q��
�G�G�L�L��O�#�x�x�}�}���C��f��5�5����
�
�c�3��/���g�~���H�H�M�M�#�s�F�3�%�q�j���$���%�k�k�Q��*��?����J��Z����5�J��k�k�J�.����w�w�|�|�J�'�'�� ����s�1D�	D�Dc���|jdk7r%|jj|j�	|jjd�	|jj�\}}}|dk(rnU|dk(r1|jr%d|_|jj|||�n	|jj|||���|jj*|_|js"|jj/�d
|_y
|j0r�|j2t4j6k(r�|j9|j:|j<�}|j:j>dk(r.d|j@vr |jCd
|j@d�}n|jEd
�}|j0jG||j<|�|j0|_|jHrd
|_$y
y
y
y
#tj
tf$rY��[wxYw#t$rY��kt$r.|dk(r|dz}tj|j|�Y���t$rmt j#d|||�tj|j|�}|dd	j%�r|j&j)||df�Y��wxYw)z%internal: finished reading image datarTrr~r`r>r=rrNrr�r)%rsrHrPrBrqrrrVrQrLrermrir�rrzrCrirjrDrArcr�rGr^rcrfr0r2rjrargrmr��convert_transparent�convertrhrb)rJrWrXrYr:�updated�masks       r.�load_endzPngImageFile.load_end�sM���;�;�!���G�G�L�L����%���G�G�L�L��O�
�#'�8�8�=�=�?� ��S�&��g�~�����D�$4�$4�&'��#����
�
�c�3��/��
?����
�
�c�3��/�#�:�X�X�%�%��
�����H�H�N�N���D�H��}�}����%�-�-�!?��*�*�T�W�W�d�.A�.A�B���7�7�<�<�5�(�^�t�y�y�-H�"�6�6���	�	�.� 9��D�#�?�?�6�2�D��
�
�#�#�G�T�-@�-@�$�G��-�-����=�=�$(�D�M�!�"@�}��;�L�L�+�.�
��
��&�
���
6��'�>��a�K�F��$�$�T�W�W�f�5�!�
?����1�3��V�D��(�(����&�9���q��8�#�#�%��'�'�.�.��Q��~�>��	
?�s1�H
�-H*�
H'�&H'�*	K �62K �+A1K �K c��d|jvr|j�d|jvrd|jvry|j�j�S)NrzRaw profile type exif)r�rU�getexif�_get_merged_dictr[s r.�_getexifzPngImageFile._getexif�sG������"��I�I�K�����"�'>�d�i�i�'O���|�|�~�.�.�0�0r-c�\��d|jvr|j�t�|�
�S)Nr)r�rUr�r�)rJr�s �r.r�zPngImageFile.getexif�s%�������"��I�I�K��w�� � r-c�^�d|jvr|j|jd�SiS)z�
        Returns a dictionary containing the XMP tags.
        Requires defusedxml to be installed.

        :returns: XMP tags in a dictionary.
        zXML:com.adobe.xmp)r��_getxmpr[s r.�getxmpzPngImageFile.getxmp�s7��#�d�i�i�/�
�L�L����#6�7�8�	
��	
r-r�)r&r'r(�format�format_descriptionrS�propertyr�r}rOrPrQrtryrr�r�r�r3r4s@r.r:r:�s_���
�F�4��A-�F�����"
+�\ �|�/�(�B1)�f1�!�
r-r:)r�)�L;1r�)rs)rs)rs)rs)rs)rs)rs)rs)rs)rs)rs)rr�rrrrrzI;16rrrrrrrc���dj|�}|jtt|��|z�|j|�t	|t	|��}|jt|��y)z'Write a PNG chunk (including CRC field)r-N)�join�write�o32r�rC�rHrWrArvs    r.�putchunkr�"sU���8�8�D�>�D��H�H�S��T��^�c�
!�"��H�H�T�N�
��v�c�{�
#�C��H�H�S��X�r-c��eZdZd�Zd�Zy)�_idatc� �||_||_yrG)rHr�)rJrHr�s   r.rKz_idat.__init__0s�������
r-c�>�|j|jd|�y)Nrv)r�rH�rJrAs  r.r�z_idat.write4s���
�
�4�7�7�G�T�*r-N�r&r'r(rKr�r,r-r.r�r�-s���+r-r�c��eZdZd�Zd�Zy)�_fdatc�.�||_||_||_yrG)rHr�r�)rJrHr�r�s    r.rKz_fdat.__init__;s�������
���r-c��|j|jdt|j�|�|xjdz
c_y)Nr>r)r�rHr�r�r�s  r.r�z_fdat.write@s/���
�
�4�7�7�G�S����%6��=������r-Nr�r,r-r.r�r�8s���
r-r�c��|jjd|jjdd��}|jjd|jjdd��}|jjd|jjdtj��}|jjd|jjdt
j��}	|rtj|�}
ntj|g|�}
g}d}|
D�]�}
tj|
�D�]m}|j|k(r|j�}n|j|�}|jj�}t|tt f�r|||d<t|tt f�r|||d<t|	tt f�r|	||d<|dz
}|�r�|d}|djd�}|djd�}|tj"k(rt%|�d	krtj&}|tj&k(ry|d
j�}t(j*j-d|j.d�}|d
}|r|j1|�}nd|j.z}|j3||�n!|tj"k(r	|dd
}n|d
}t5j6|jd�|jd��}|j9d��}|sL||jd�k(r8||jd�k(r$|ddxx|jd|�z
cc<��Nd}d|vr||d<|j;|||d����p���t%|�dk(r
|s|dd
S||dt=t%|��t=|��|rS|j|k7r|j|�}t?j@|tC||�dd|j.zd|fg�d}tE|�D�]t\}}|d
}|d
sd|j.z}n|d
}|j1|�}|j.}|d}tGtI|d��}|jd|�}|jd|	�}||dt=|�t=|d�t=|d�t=|d�t=|d�tK|�tKd�tM|�tM|��|dz
}|dk(r7|s5t?j@|tC||�dd|j.zd|fg���3tO|||�}t?j@||dd|j.zd|fg�|jP}��wy)Nr#rrr%r'r����encoderinforrar)rrrrr�r����F)�
alpha_only)rar�r�sacTLr�r`r"))r�rIr�r%r)r0r1�	itertools�chainr
�Iteratorrmr�r|r��listr�r+r�r*rrkrlrn�croprhr�subtract_modulo�getbboxrcr�r�_saver��	enumerate�int�round�o16r
r�r�)rarHr�rRr��
append_imagesr#rr%r'r��	im_frames�frame_count�im_seq�im_framer��previous�
prev_disposal�
prev_blend�base_imrdr��deltar�rV�
frame_datarn�frame_duration�frame_disposal�frame_blend�fdat_chunkss                               r.�_write_multiple_framesr�EsR���~�~�!�!�*�b�g�g�k�k�*�a�.H�I�H�
�>�>���f�b�g�g�k�k�&�!�&<�=�D��~�~�!�!�*�b�g�g�k�k�*�h�FV�FV�.W�X�H��N�N���w������G�U�_�_�(M�N�E�����
�.�������m�4���I��K��4Y��%�.�.�v�6�3	Y�H��}�}��'�#�=�=�?��#�+�+�G�4���.�.�-�-�/�K��(�T�5�M�2�*2�;�*?��J�'��(�T�5�M�2�*2�;�*?��J�'��%�$���/�',�[�'9��G�$��1��K��$�R�=�� (�� 7� ;� ;�J� G�
�%�m�4�8�8��A�
� �H�$8�$8�8�S��^�a�=O�$,�$:�$:�M� �H�$:�$:�:�&�t�n�1�1�3�G�#�j�j�o�o�f�b�g�g�|�L�G�#�F�+�D��")�,�,�t�"4��%����/���M�M�'�4�0�"�h�&:�&:�:�'��m�D�1�G�&�t�n�G�"�2�2��$�$�V�,�g�o�o�f�.E����}�}��}�6���%�����)D�D�"�k�o�o�g�&>�>��]�+�J�7�;�?�?�"�H�<��7������,�*2��J�'����H�d�;�W�X�g3	Y�4Y�l�9�~���=���|�D�!�!�
�
���C�	�N���D�	�	��
�7�7�g�����G�$�B�����E�"�e�,��v����7G��G�/T�.U�V��G�&�y�1�**���z��d�#���&�!��H�M�M�)�D��f�%�D��}�}�T�*�H��}�}�� ��/���U�;�z�#:�;�<��$����X�>��!�o�o�g�u�5��
�����L���Q��L���Q��L���Q��L���Q��L������I��~���{�O�	
�	�1����A�:�m��O�O���b�%� ���(�-�-�/��G�<�=�
� ��E�7�3�K��O�O�����(�-�-�/��G�<�=�
�
"�)�)�G�U**r-c�"�t|||d��y)NT)�save_all)r�)rarH�filenames   r.�	_save_allr��s��	�"�b�(�T�*r-Fc��|r�|jjd|jjd��}t�}|jjdg�}t	j
|g|�D]7}t
j|�D]}	|j|	j���9dD]}
|
|vs�n|j�}
n|j}
|
dk(r�d|jvrtd|jdzd�}nL|jr>ttt|jj�d�dzd�d�}nd}|d	kr|d
krd}n
|dkrd
}nd}|
�d|��}
|jjd
d�|jjdd�|jjdd�|jjdd�f|_	t"|
\}
}
|j)t*�||dt-|j.d�t-|j.d�|
ddd�gd�}|jjd|jjd��}|r8d}|dzt1j2|�z}||d|�|j5d�|jjd�}|rrgd �}|j6D]_}|dd
\}}||vr|j5|�||||��+||vr||||��:|dd
j9�s�N|d
d}|r�V||||��a|jdk(rOdz}|j:j=d!�d|}t|�|kr|dz
}t|�|kr�||d"|�|jjd#|jjd#d��}|s|dk(r�|jdk(rM}t?|t@�r||d$|d|��ntdtd%|��}d&|zdz}||d$|d|�n�|jd'vr*tdtd(|��}||d$tC|��n�|jd!k(r2|\}}} ||d$tC|�tC|�ztC| �z�nrd#|jvrdd)}t'|��|jdk(rH|j:jE�d*k(r+|j:j=d*d+�}}||d$|d|�|jjd,�}!|!rB||d-t-tG|!dd.zd/z��t-tG|!dd.zd/z��d0�|r=d1d2g}|j6D]*}|dd
\}}||vs�|j5|�||||��,|jjd3�}"|"rKt?|"tHjJ�r|"jMd4�}"|"jOd5�r|"d6d}"||d7|"�|rtQ||||
�}|r3tSjT|tW||�d8d9|j.zd|
fg�|r?|j6D]0}|dd
\}}|dd
j9�s�|d
d}|s�'||||��2||d:d�tY|d;�r|j[�yy#t$$r}d|
�d�}t'|�|�d}~wwxYw)<Nr�r�)rrrr�bitsr�r!r rr�;�optimizeF�compress_levelr��
compress_type�
dictionaryr-zcannot write mode z as PNGsIHDRrr�)scHRMsgAMAssBIT�sRGBstIMEr�sICC Profiler�siCCPr��pnginfo)ssPLTr�r�r�rsPLTEr�stRNS���r�i��z%cannot use transparency for this moder�Ar�spHYsr�g�?�sbKGDshISTrrrr"seXIfr�r�r~�flush).r�rIr��setr�r�r
r�r�rmrNrwrK�maxr��getdata�
encoderconfig�	_OUTMODES�KeyErrorryr�r6r�rnr4r��remover�rDra�
getpaletter�r�r��getpalettemoder�r�Exif�tobytes�
startswithr�rr�r��hasattrr�)#rarHr�r�r�r��modesr�r�r�rm�colorsr�rRrur=r��icc�namerAr��chunks_multiple_allowed�
info_chunkrWr��palette_byte_number�
palette_bytesr��alpha_bytes�alpha�red�green�bluer�rs#                                   r.r�r��s�������*�*��R�W�W�[�[��9�
�
�������*�*�?�B�?�
��o�o�r�d�M�:�	)�F�)�2�2�6�:�
)���	�	�(�-�-�(�
)�	)�)�	�D��u�}��	��9�9�;�D��w�w���s�{��R�^�^�#���b�n�n�V�4�4�c�:�F��z�z��S��R�Z�Z�%7�%7�%9�!�%<�!=��!B�C�H�!�L�����R�<���{����1�������V�1�T�F�#�D�	�����:�u�-�
�����+�R�0�
�����?�B�/�
�����<��-�	�B��"�!�$��
����H�H�V��	�
���B�G�G�A�J���B�G�G�A�J���
�
�
�	�;�F�
�.�.�
�
�]�B�G�G�K�K�
�,F�
G�C�
����g�~��
�
�c� 2�2��
�b�'�4� �	�
�
�g��
�>�>���i�(�D��"F���+�+�	)�J�"�2�A��I�C���f�}��
�
�c�"��b�#�t�$��/�/��b�#�t�$��Q�q��!�!�#�'��!�_�
�!��"�c�4�(�	)�
�w�w�#�~�$�q�j�����(�(��/�0D�1D�E�
��-� �#6�6��U�"�M��-� �#6�6�
�b�'�=�)��>�>�%�%�n�b�g�g�k�k�.�RV�6W�X�L��|�q�(�
�7�7�c�>� �K��,��.��b�'�<���#=�>�"�1�c�#�|�&<�=���,�.��6���b�'�5��+�#6�7�
�W�W��
'��q�#�e�\�":�;�L��"�g�s�<�0�1�
�W�W��
�+��C����"�g�s�3�x�#�e�*�4�s�4�y�@�A�����/�>���c�l�"�
�7�7�c�>�b�e�e�2�2�4��>��E�E�$�$�V�S�1�E� �K��"�g�u�\�k�2�3�
�.�.�
�
�U�
#�C�
�
�����C��F�V�O�c�)�*�+���C��F�V�O�c�)�*�+��	
���7�#���+�+�	%�J�"�2�A��I�C���f�}��
�
�c�"��b�#�t�$�		%��>�>���f�%�D���d�E�J�J�'��<�<��?�D��?�?�?�+����8�D�
�b�'�4� ��
#���E�7�M�=�
��
�����E�"�e�,��v����7G��G�/T�.U�V���+�+�	)�J�"�2�A��I�C���1�Q�x���!�'��!�_�
���"�c�4�(�
	)�
�"�g�s���r�7��
���
���O�"�"�4�&��0���c�l��!��"�s�'[�	[=�&[8�8[=c��Gd�d�}d�}|�}	||_t||d|�|`|jS#|`wxYw)z4Return a list of PNG chunks representing this image.c��eZdZgZd�Zd�Zy)�getchunks.<locals>.collectorc��yrGr,r�s  r.r�z"getchunks.<locals>.collector.write�s��r-c�:�|jj|�yrG)rArc)rJr�s  r.rcz#getchunks.<locals>.collector.append�s���I�I���U�#r-N)r&r'r(rAr�rcr,r-r.�	collectorr��s����	�	$r-r�c��dj|�}tt|t|���}|j|||f�y)Nr-)r�r�rCrcr�s    r.rczgetchunks.<locals>.append�s7���x�x��~���&��v�c�{�+�,��
�	�	�3��c�"�#r-N)r�r�rA)ra�paramsr�rcrHs     r.�	getchunksr��sK��$�$�$�

��B�����
�b�"�d�F�#��N�
�7�7�N��
�N�s�9�=z.pngz.apngz	image/png)r)?�
__future__rr��logging�rerqrr4�enumrr�rrrr	r
�_binaryrr�rrRr
rr�rr��	getLoggerr&ri�compiler�rSr6r�r��	SAFEBLOCKr7r�r%r0r>rCrEr�r�r�r�r8r:r�r�r�r�r�r�r�r��
register_openr��
register_save�register_save_all�register_extensions�
register_mimer,r-r.�<module>rs.��B#���	�
����G�G�!�!��!�!�	��	�	�8�	$��	����L�	!�	'�	'��
��
����
��
������
��
!�+
��2�"�*�*�0�1���$�$���
�~�%����w��*�G���/�V�V�r�3��,M3�M3�hS4��S4�t
 �L
�9�&�&�L
�h

����	�
�	�"�
#����	��!�!
�	�(�+�+�
�
�*�D+�#+�U�}�H�>����L�'�'��w�?�����L�'�'��/������+�+�Y�7�����,�-�-���/@�A�����L�'�'��5r-

Zerion Mini Shell 1.0