%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__/Image.cpython-312.pyc

�

��eP
�
��ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZmZddlmZddlmZ	ddlmZddlmZmZmZmZmZmZdd	lmZm Z m!Z!dd
l"m#Z#m$Z$ejJe&�Z'Gd�de(�Z)Gd
�de*�Z+e,d�Z-	ddlm.Z/ee0e/dd�k7rde0e/dd��de��Z1ee1��	dZ7	ddl8Z8d�Z9Gd�de�Z:Gd�de�Z;Gd�de�Z<e<jzd e<j|d!e<j~d!e<j�d"e<j�d#iZBGd$�d%e�ZCGd&�d'e�ZDGd(�d)e�ZEe
j�e&ZGe:e;e<eCeDeEfD]'ZeD] ZHeIeGeHj�eHj���"�)eLe/d*�r<e/j�ZMe/j�ZNe/j�ZOe/j�ZPe/j�ZQgZRiZSiZTiZUiZViZWiZXiZYe
j�d+k(rd,nd-Z[d.�Z\gd/�Z]d0Z^d1�Z_d2�Z`d3�Zad4�Zbdacd5�Zdd6�Zed�d7�Zfd�d8�ZgGd9�d:�Zhd;�ZiGd<�d=�ZjGd>�d?�ZkGd@�dA�ZldB�ZmdC�Znd�d�dD�Z3d�d�dE�Zod�dF�Zpd�dG�ZqdH�ZrdI�ZsidJdK�dLdM�dNdO�dPdQ�dRdS�dTdU�dVdW�dXdY�dZd[�d\d]�d^d_�d`da�dbdc�ddde�dfdg�dhdi�djdk�dldmdne[dozfdpdne[dqzfdri�Ztds�Zud�d�dt�Zvdu�Zwdv�Zxdw�Zydx�Zzdy�Z{d�d�dz�Z|d{�Z}d|�Z~d}�Zd�d~�Z�d�Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d�d��Z�e��e�je/�j�Gd��d�e�Z�y#e$rdZY���wxYw#e$ryZ2e#jfed��Z/e4e2�jkd�rejlde(��e4e2�jkd�rejle4e2�e(��dZ2[2wwxYw#e$rdZ8Y���wxYw)��)�annotationsN)�Callable�MutableMapping)�IntEnum)�Path)�ElementTree�)�ExifTags�	ImageMode�TiffTags�UnidentifiedImageError�__version__�_plugins)�i32le�o32be�o32le)�
DeferredError�is_pathc��eZdZy)�DecompressionBombWarningN��__name__�
__module__�__qualname__���+/usr/lib/python3/dist-packages/PIL/Image.pyrrB���rrc��eZdZy)�DecompressionBombErrorNrrrrr r Frrr iUUU)�_imaging�PILLOW_VERSIONzUThe _imaging extension was built for another version of Pillow or PIL:
Core version: z
Pillow version: z'The _imaging C module is not installed.zModule use of pythonz?The _imaging extension was built for another version of Python.zThe _imaging extensionFc��t|d�S)z�
    Checks if an object is an image object.

    .. warning::

       This function is for internal use only.

    :param t: object to check if it's an image
    :returns: True if the object is an image
    �im)�hasattr)�ts r�isImageTyper'ws���1�d��rc�(�eZdZdZdZdZdZdZdZdZ	y)	�	Transposerr	�����N)
rrr�FLIP_LEFT_RIGHT�FLIP_TOP_BOTTOM�	ROTATE_90�
ROTATE_180�
ROTATE_270�	TRANSPOSE�
TRANSVERSErrrr)r)�s%���O��O��I��J��J��I��Jrr)c� �eZdZdZdZdZdZdZy)�	Transformrr	r*r+r,N)rrr�AFFINE�EXTENT�PERSPECTIVE�QUAD�MESHrrrr7r7�s��
�F�
�F��K��D��Drr7c�$�eZdZdZdZdZdZdZdZy)�
Resamplingrr,r*r-r+r	N)	rrr�NEAREST�BOX�BILINEAR�HAMMING�BICUBIC�LANCZOSrrrr>r>�s ���G�
�C��H��G��G��Grr>��?��?�@g@c��eZdZdZdZdZdZy)�Ditherrr	r*r+N)rrr�NONE�ORDERED�	RASTERIZE�FLOYDSTEINBERGrrrrIrI�s���D��G��I��NrrIc��eZdZdZdZy)�Paletterr	N)rrr�WEB�ADAPTIVErrrrOrO�s��
�C��HrrOc��eZdZdZdZdZdZy)�Quantizerr	r*r+N)rrr�	MEDIANCUT�MAXCOVERAGE�
FASTOCTREE�
LIBIMAGEQUANTrrrrSrS�s���I��K��J��MrrS�DEFAULT_STRATEGY�little�<�>c���tj|j�}|j|jf}t|j�}|dk7r||fz
}||jfS�Nr	)r�getmode�mode�height�width�len�bands�typestr)r$�m�shape�extras    r�_conv_type_shaperh�sW�����"�'�'�"�A�
�Y�Y����!�E�����L�E���z�
�%�����!�)�)��r)�1�CMYK�F�HSV�I�L�LAB�P�RGB�RGBA�RGBX�YCbCr)rnrprsrrrj�I;16zI;16L�I;16Bc�@�tj|�jS)a%
    Gets the "base" mode for given mode.  This function returns "L" for
    images that contain grayscale data, and "RGB" for images that
    contain color data.

    :param mode: Input mode.
    :returns: "L" or "RGB".
    :exception KeyError: If the input mode was not a standard mode.
    )rr^�basemode�r_s r�getmodebaserz�s�����T�"�+�+�+rc�@�tj|�jS)a
    Gets the storage type mode.  Given a mode, this function returns a
    single-layer mode suitable for storing individual bands.

    :param mode: Input mode.
    :returns: "L", "I", or "F".
    :exception KeyError: If the input mode was not a standard mode.
    )rr^�basetyperys r�getmodetyper}s�����T�"�+�+�+rc�@�tj|�jS)a�
    Gets a list of individual band names.  Given a mode, this function returns
    a tuple containing the names of individual bands (use
    :py:method:`~PIL.Image.getmodetype` to get the mode used to store each
    individual band.

    :param mode: Input mode.
    :returns: A tuple containing band names.  The length of the tuple
        gives the number of bands in an image of the given mode.
    :exception KeyError: If the input mode was not a standard mode.
    )rr^rcrys r�getmodebandnamesrs�����T�"�(�(�(rc�R�ttj|�j�S)z�
    Gets the number of individual bands for this mode.

    :param mode: Input mode.
    :returns: The number of bands in this mode.
    :exception KeyError: If the input mode was not a standard mode.
    )rbrr^rcrys r�getmodebandsr�s ���y� � ��&�,�,�-�-rc�.�tdk\ry	ddlm}|sJ�		ddlm}|sJ�		ddlm}|sJ�		ddlm}|sJ�		ddlm}|sJ�	day#t$rY�>wxYw#t$rY�AwxYw#t$rY�DwxYw#t$rY�GwxYw#t$rYdaywxYw)z|
    Explicitly loads BMP, GIF, JPEG, PPM and PPM file format drivers.

    It is called when opening or saving images.
    r	N)�BmpImagePlugin)�GifImagePlugin)�JpegImagePlugin)�PpmImagePlugin)�PngImagePlugin)�_initialized�r��ImportErrorr�r�r�r�)r�r�r�r�r�s     r�preinitr�.s����q���
�$���~�
�$���~�
�%����
�$���~�
�$���~��L��7�
��
���
��
���
��
���
��
���
���L�
�sU�
A
�
A�
A(�
A7�
B�
	A�A�	A%�$A%�(	A4�3A4�7	B�B�	B�Bc�J�tdk\rytjd�d}tD]<}	tjd|�t
|�d|��t�t�g��>tstrdayy#t$r!}tjd||�Yd}~�td}~wwxYw)z�
    Explicitly initializes the Python Imaging Library. This function
    loads all available file format drivers.

    It is called when opening or saving images if :py:meth:`~preinit()` is
    insufficient, and by :py:meth:`~PIL.features.pilinfo`.
    r*r�.zImporting %szImage: failed to import %s: %sNr	)r�r�
rpartitionr�logger�debug�
__import__�globals�localsr��OPEN�SAVE)�parent_name�plugin�es   r�initr�[s����q����%�%�c�*�1�-�K��F��	F��L�L���0��+��a��x�0�'�)�V�X�r�J�F��t�������	F��L�L�9�6�1�E�E��	F�s�9A8�8	B"�B�B"c��|�d}nt|t�s|f}	t|}||g||z���S#t$rYnwxYw	t	t
|dz�}n##t$r}d|�d�}t|�|�d}~wwxYw||g||z���S)Nr�_decoderzdecoder � not available)�
isinstance�tuple�DECODERS�KeyError�getattr�core�AttributeError�OSError)r_�decoder_name�argsrg�decoderr��msgs       r�_getdecoderr�y����|���
��e�
$��w��,��<�(���t�+�d�U�l�+�+���
��
��
"��$��z� 9�:����"����n�5���c�l��!��"���4�'�$��,�'�'�#�	/�	;�;�A�	A3�A.�.A3c��|�d}nt|t�s|f}	t|}||g||z���S#t$rYnwxYw	t	t
|dz�}n##t$r}d|�d�}t|�|�d}~wwxYw||g||z���S)Nr�_encoderzencoder r�)r�r��ENCODERSr�r�r�r�r�)r_�encoder_namer�rg�encoderr�r�s       r�_getencoderr��r�r�c�>�eZdZd�Zd�Zd�ZeZd�Zd�Zd�Z	e	Z
d�Zy)	�_Ec� �||_||_y�N)�scale�offset)�selfr�r�s   r�__init__z_E.__init__�s����
���rc�F�t|j|j�Sr�)r�r�r��r�s r�__neg__z
_E.__neg__�s���4�:�:�+����|�,�,rc���t|t�r:t|j|jz|j|jz�St|j|j|z�Sr�)r�r�r�r��r��others  r�__add__z
_E.__add__�sM���e�R� ��d�j�j�5�;�;�.����e�l�l�0J�K�K��$�*�*�d�k�k�E�1�2�2rc��||zSr�rr�s  r�__sub__z
_E.__sub__�s���u�f�}�rc��||zSr�rr�s  r�__rsub__z_E.__rsub__�s����u�}�rc�z�t|t�rtSt|j|z|j|z�Sr��r�r��NotImplementedr�r�r�s  r�__mul__z
_E.__mul__��1���e�R� �!�!��$�*�*�u�$�d�k�k�E�&9�:�:rc�z�t|t�rtSt|j|z|j|z�Sr�r�r�s  r�__truediv__z_E.__truediv__�r�rN)rrrr�r�r��__radd__r�r�r��__rmul__r�rrrr�r��s3���-�3�
�H���;�
�H�;rr�c�~�|tdd��}t|t�r|j|jfSd|fS�Nr	r)r�r�r�r�)�expr�as  r�_getscaleoffsetr��s6���R��1�X��A�",�Q��"3�A�G�G�Q�X�X��?�!�Q��?rc�4�eZdZUdZdZded<dZded<dZd�Ze	d��Z
e	d	��Ze	d
��Ze	d��Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZdYd�Zd�Zd�Zd�Zd�Zd�Zd�Ze	d��Zd�Zd�ZdZd�Zd[d�Z dZd�Z!d �Z"d!�Z#ddde$jJd"fd#�Z&d"dd$de'jPfd%�Z)d\d&�Z*e*Z+d]d\d'�Z,d(�Z-d)�Z.d]d*�Z/d+�Z0d,�Z1dd-�d.�Z2d^d/�Z3d]d0�Z4d1�Z5d2�Z6d3�Z7d4�Z8d5�Z9d6�Z:d_d7�Z;e	d`d8��Z<d9�Z=d:�Z>d;�Z?dYd<�Z@dYd=�ZAdYdad>�ZBdbd?�ZCd]d@�ZDdA�ZEdcdB�ZFd_dC�ZGdD�ZHd]dE�ZIdF�ZJdddG�ZKd]dH�ZLeMj�d$dddfdI�ZOd]dadJ�ZPd\dK�ZQd]dL�ZRdM�ZSdN�ZTdedO�ZUeMj�dPfdQ�ZWdeMj�dRdf	d\dS�ZXeMj�dRfdT�ZYdU�ZZdV�Z[dW�Z\dX�Z]y)f�ImageaD
    This class represents an image object.  To create
    :py:class:`~PIL.Image.Image` objects, use the appropriate factory
    functions.  There's hardly ever any reason to call the Image constructor
    directly.

    * :py:func:`~PIL.Image.open`
    * :py:func:`~PIL.Image.new`
    * :py:func:`~PIL.Image.frombytes`
    Nz
str | None�format�format_descriptionTc�t�d|_d|_d|_d|_i|_d|_d|_d|_y)Nr��rrr)r$�_mode�_size�palette�info�readonly�pyaccess�_exifr�s rr�zImage.__init__�s<�������
���
������	���
���
���
rc� �|jdS�Nr��sizer�s rrazImage.width�����y�y��|�rc� �|jdSr]r�r�s rr`zImage.height�r�rc��|jSr�)r�r�s rr�z
Image.size�����z�z�rc��|jSr�)r�r�s rr_z
Image.mode�r�rc�T�t�}||_|j|_|j|_|jdvrG|jr |jj�|_nddlm	}|j�|_|jj�|_
|S)N�rp�PAr	��ImagePalette)r�r$r_r�r�r�r��copyr�r�r�)r�r$�newr�s    r�_newz
Image._newsw���g������G�G��	��G�G��	�
�7�7�k�!��|�|�"�l�l�/�/�1���*�*�7�7�9����9�9�>�>�#����
rc��|Sr�rr�s r�	__enter__zImage.__enter__s���rc��t|dd�rL|j|jk7r|jj�t	td��|_|jr|jj�yy)N�_fpF�Operation on closed image)r�r��fp�closer�
ValueErrorr�s r�	_close_fpzImage._close_fpsW���4���&��x�x�4�7�7�"������ �$�Z�0K�%L�M�D�H��7�7��G�G�M�M�O�rc�f�t|d�r%t|dd�r|j�d|_yy)Nr��
_exclusive_fpF)r%r�r�r�)r�r�s  r�__exit__zImage.__exit__s.���4����t�_�e�4���� ��D�G�rc��t|d�r	|j�d|_t
|dd�rd|_ttd��|_
y#t$r }tjd|�Yd}~�Rd}~wwxYw)a�
        Closes the file pointer, if possible.

        This operation will destroy the image core and release its memory.
        The image data will be unusable afterward.

        This function is required to close images that have multiple frames or
        have not had their file read and closed by the
        :py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for
        more information.
        r�NzError closing: %s�mapr�)r%r�r��	Exceptionr�r�r�r�rr�r$)r�r�s  rr�zImage.close#sq���4���
7���� �����4���%��D�H�
 �
�+F� G�H�����
7����0�#�6�6��
7�s�A�	A<�A7�7A<c�~�|j�|jj�|_d|_d|_yr�)�loadr$r�r�r�r�s r�_copyzImage._copy>s*���	�	���'�'�,�,�.�����
���
rc�^�|jr|j�y|j�yr�)r�rrr�s r�_ensure_mutablezImage._ensure_mutableDs���=�=��J�J�L��I�I�Krc�8�d}|rd|z}|s.tj|�\}}tj|�n|}|j	|�s||z}|j�|r|dk(r|jj|�|S|j||fi|��|S)Nr�r��PPM)	�tempfile�mkstemp�osr��endswithrr$�save_ppm�save)r��filer��options�suffix�f�filenames       r�_dumpzImage._dumpJs�������6�\�F��"�*�*�6�2�K�A�x��H�H�Q�K��H��$�$�V�,�#�f�,���	�	����5���G�G���X�&���
�D�I�I�h��2�'�2��rc�`�|j|juxr�|j|jk(xrz|j|jk(xr_|j|jk(xrD|j	�|j	�k(xr!|j�|j�k(Sr�)�	__class__r_r�r��
getpalette�tobytesr�s  r�__eq__zImage.__eq__`s����N�N�e�o�o�-�
2��	�	�U�Z�Z�'�
2��	�	�U�Z�Z�'�
2��	�	�U�Z�Z�'�
2����!�U�%5�%5�%7�7�	
2�
����%�-�-�/�1�
	
rc	���d|jj|jj|j|jd|jdt|�fzS)Nz(<%s.%s image mode=%s size=%dx%d at 0x%X>rr	)rrrr_r��idr�s r�__repr__zImage.__repr__jsR��9��N�N�%�%��N�N�#�#��I�I��I�I�a�L��I�I�a�L��t�H�
=
�
�	
rc	���|jd|jj|jj|j|j
d|j
dfz�y)z"IPython plain text display supportz <%s.%s image mode=%s size=%dx%d>rr	N)�textrrrr_r�)r��p�cycles   r�
_repr_pretty_zImage._repr_pretty_tsT��
	
���.����)�)����'�'��	�	��	�	�!���	�	�!���
�		
rc��tj�}	|j||fi|��|j	�S#t$rYywxYw)z�Helper function for iPython display hook.

        :param image_format: Image format.
        :returns: image as bytes, saved into the given format.
        N)�io�BytesIOrr��getvalue)r��image_format�kwargs�bs    r�_repr_imagezImage._repr_image�sK��
�J�J�L��	��D�I�I�a��0��0��z�z�|����	��	�s�:�	A�Ac�(�|jdd��S)zjiPython display hook support for PNG format.

        :returns: PNG version of the image as bytes
        �PNGr	)�compress_level�r'r�s r�
_repr_png_zImage._repr_png_�s��
����a��8�8rc�$�|jd�S)zliPython display hook support for JPEG format.

        :returns: JPEG version of the image as bytes
        �JPEGr+r�s r�_repr_jpeg_zImage._repr_jpeg_�s��
����'�'rc��ddi}	|jdk(r|jdd�|d<n|j�|d<t|�\|d
<|d<|S#t$rg}t|tt
f�sK	ddl}ddlm}||j�|d	�krtj|��#t$rY�wxYw�d}~wwxYw)N�versionr+ri�rawrn�datar)�parsez1.23rfrd)r_rr�r��MemoryError�RecursionError�numpy�packaging.versionr4r�warnings�warnr�rh)r�r�r�r7�
parse_versions     r�__array_interface__zImage.__array_interface__�s����!�n��	��y�y�C��#�l�l�5�#�6��F��"�l�l�n��F��(8��'=�$��G��c�)�n��
���
	��a�+�~�!>�?�)� �H�%�U�%6�%6�7�-��:O�O� �
�
�a�(���#���
���

��
	�s;�8A�	C�B?�4
B/�>1B?�/	B;�8B?�:B;�;B?�?Cc��|j�}|j|j|j|j	�|gSr�)rr�r_r�r)r��im_datas  r�__getstate__zImage.__getstate__�s1���,�,�.���	�	�4�9�9�d�i�i����1B�G�L�Lrc���tj|�|\}}}}}||_||_||_tj||�|_|dvr|r|j|�|j|�y)N�rn�LArpr�)
r�r�r�r�r�r�r�r$�
putpalette�	frombytes)r��stater�r_r�r�r3s       r�__setstate__zImage.__setstate__�sh��
���t��*/�'��d�D�'�4���	���
���
��(�(�4��&����)�)�g��O�O�G�$����t�rc��t|�dk(rt|dt�r|d}|dk(r|dk(r|j}|j	�|j
dk(s|jdk(ryt|j||�}|j|j�td|jddz�}g}	|j|�\}}}|j|�|rn�*|dkrd|�d	�}	t|	��dj|�S)
a!
        Return image as a bytes object.

        .. warning::

            This method returns the raw image data from the internal
            storage.  For compressed image data (e.g. PNG, JPEG) use
            :meth:`~.save`, with a BytesIO parameter for in-memory
            data.

        :param encoder_name: What encoder to use.  The default is to
                             use the standard "raw" encoder.

                             A list of C encoders can be seen under
                             codecs section of the function array in
                             :file:`_imaging.c`. Python encoders are
                             registered within the relevant plugins.
        :param args: Extra arguments to the encoder.
        :returns: A :py:class:`bytes` object.
        r	rr2rrir,zencoder error z in tobytes)rbr�r�r_rrar`r��setimager$�maxr��encode�append�RuntimeError�join)
r�r�r�r��bufsize�output�bytes_consumed�errcoder3r�s
          rrz
Image.tobytes�s��.�t�9��>�j��a��%�8���7�D��5� �T�R�Z��9�9�D��	�	���:�:��?�d�k�k�Q�.��
��	�	�<��6��	�
�
�4�7�7���e�T�Y�Y�q�\�A�-�.�����,-�H�H�W�,=�)�N�G�T��M�M�$����	�
�Q�;�"�7�)�;�7�C��s�#�#��x�x���rc�Z�|j�|jdk7r
d}t|��|jd�}dj	d|�d|j
d�d�j
d	�d|�d
|j
d�d�j
d	�d|�d
�j
d	�|dg�S)a-
        Returns the image converted to an X11 bitmap.

        .. note:: This method only works for mode "1" images.

        :param name: The name prefix to use for the bitmap variables.
        :returns: A string containing an X11 bitmap.
        :raises ValueError: If the mode is not "1"
        riznot a bitmap�xbmrz#define z_width r�
�asciiz_height r	zstatic char z_bits[] = {
s};)rr_r�rrMr�rJ)r��namer�r3s    r�tobitmapzImage.tobitmap�s���	
�	�	���9�9��� �C��S�/�!��|�|�E�"���x�x��4�&���	�	�!��~�R�8�?�?��H��4�&�����1���b�9�@�@��I��t�f�N�3�:�:�7�C���
�
�	
rc��|jdk(s|jdk(ryt|�dk(rt|dt�r|d}|dk(r|dk(r|j
}t
|j
||�}|j|j�|j|�}|ddk\r
d}t|��|ddk7r
d}t|��y)z�
        Loads this image with pixel data from a bytes object.

        This method is similar to the :py:func:`~PIL.Image.frombytes` function,
        but loads data into this image instead of creating a new image object.
        rNr	r2rznot enough image datazcannot decode image data)rar`rbr�r�r_r�rHr$�decoder�)r�r3r�r��d�sr�s       rrDzImage.frombytess����:�:��?�d�k�k�Q�.���t�9��>�j��a��%�8���7�D��5� �T�R�Z��9�9�D�
��	�	�<��6��	�
�
�4�7�7��
�H�H�T�N���Q�4�1�9�)�C��S�/�!��Q�4�1�9�,�C��S�/�!�rc��|j��c|j�rV|jj�r?|jj�\}}|jj	||�d|j_d|j_d|jvr�|dvr�t|jdt�r*|jj|jdd�n(|jj|jd�d|j_nQ|jd�rdnd}||j_|jj||�|j_|j��tr]trW|j r|j Sddlm}|j'||j(�|_|j r|j S|jj+|j(�Sy)	a�
        Allocates storage for the image and loads the pixel data.  In
        normal cases, you don't need to call this method, since the
        Image class automatically loads an opened image when it is
        accessed for the first time.

        If the file associated with the image was opened by Pillow, then this
        method will close it. The exception to this is if the image has
        multiple frames, in which case the file will be left open for seek
        operations. See :ref:`file-handling` for more information.

        :returns: An image access object.
        :rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess`
        Nr�transparency�rBr�rrrqr	)�PyAccess)r$r��dirty�getdatarC�rawmoder�r��int�putpalettealpha�putpalettealphasr_�
startswithr�cffi�USE_CFFI_ACCESSr�r�r_r�r��pixel_access)r�r_�arr�palette_moder_s     rrz
Image.load4so���7�7��4�<�<�D�L�L�4F�4F����,�,�.�I�D�#��G�G���t�S�)�!"�D�L�L��#'�D�L�L� �����*�t�|�/C��d�i�i��7��=��G�G�+�+�D�I�I�n�,E�q�I��G�G�,�,�T�Y�Y�~�-F�G�$*����!�)-����)@�v�e��$0����!�'+�w�w�'9�'9�,��'U����$��7�7�����=�=��=�=�(�&� (���T�4�=�=� A��
��=�=��=�=�(��7�7�'�'��
�
�6�6�rc��y)as
        Verifies the contents of a file. For data read from a file, this
        method attempts to determine if the file is broken, without
        actually decoding the image data.  If this method finds any
        problems, it raises suitable exceptions.  If you need to load
        the image after using this method, you must reopen the image
        file.
        Nrr�s r�verifyzImage.verify_s��	
r�c	��
����|j�d|jv}|s=|jdk(r.|jr|jj}nd}|dk(r|rd}|r||jk(r�s|j	�S�r�|dvr
d}t|��|jj|��}|j|�}	|r�|jjdk(rg|	jd�d��|d	k(r
�����n7t|�dk(r)t���fd
�tdt���D����|	jd<|	S|dk(r |jdk(r|j|�Sd}
d
}|�r|jdvr|dvs|jdk(rL|dk(rG|j|jj||jd��}	|	jd=|	S|jdvr�|dvr�|jd}t|t �rt#j$d�d}�nIt'|jd�}
|jdk(rJ|
j)|j�t|t�rd}	|
jj+||�}|�d}
n�|
j/d|�|dvr|
j1|�}
n|
j1d�}
|
j3d�}
n�|jdk(r{|dvrw|jd}d}t|t �r|jj5|�n:t|t6�r|jj9|d�n
d}t|��|dk(r�|t:j<k(r�|jj|�}|j|�}	ddlm }|jAd|	jjCd��|	_|r
|	jd=|
�,	|	jj+|
|	�|	jd<|	S|	Sd|j|fvr�|jdk(r|n|j}|dvrtddlm#}|jId�}|jId�}|jdk(r||gn||g}|jK|d|d|j|�}|jM|�S|�tNjP}	|jj1||�}|j|�}	|dk(r?|t:j<k7r,ddlm }|jAd|jCd��|	_|r
|	jd=|
�J|	jdk(r,	|	jj+|
|	�|	jd<|	S|
|	jd<|	S#t
$r(}t-|�dk(rd}nt|�|�Yd}~��Ed}~wwxYw#tD$r&|	jd=t#j$d�Y|	SwxYw#t
$rw	tS|j�}||jk(r�|jj1|�}|j1||�}n#tT$r}d}t|�|�d}~wwxYwY���wxYw#t
$r;}|	jd=t-|�dk7rt#j$d�Yd}~|	Sd}~wwxYw) a�
        Returns a converted copy of this image. For the "P" mode, this
        method translates pixels through the palette.  If mode is
        omitted, a mode is chosen so that all information in the image
        and the palette can be represented without a palette.

        The current version supports all possible conversions between
        "L", "RGB" and "CMYK". The ``matrix`` argument only supports "L"
        and "RGB".

        When translating a color image to grayscale (mode "L"),
        the library uses the ITU-R 601-2 luma transform::

            L = R * 299/1000 + G * 587/1000 + B * 114/1000

        The default method of converting a grayscale ("L") or "RGB"
        image into a bilevel (mode "1") image uses Floyd-Steinberg
        dither to approximate the original image luminosity levels. If
        dither is ``None``, all values larger than 127 are set to 255 (white),
        all other values to 0 (black). To use other thresholds, use the
        :py:meth:`~PIL.Image.Image.point` method.

        When converting from "RGBA" to "P" without a ``matrix`` argument,
        this passes the operation to :py:meth:`~PIL.Image.Image.quantize`,
        and ``dither`` and ``palette`` are ignored.

        When converting from "PA", if an "RGBA" palette is present, the alpha
        channel from the image will be used instead of the values from the palette.

        :param mode: The requested mode. See: :ref:`concept-modes`.
        :param matrix: An optional conversion matrix.  If given, this
           should be 4- or 12-tuple containing floating point values.
        :param dither: Dithering method, used when converting from
           mode "RGB" to "P" or from "RGB" or "L" to "1".
           Available methods are :data:`Dither.NONE` or :data:`Dither.FLOYDSTEINBERG`
           (default). Note that this is not used when ``matrix`` is supplied.
        :param palette: Palette to use when converting from mode "RGB"
           to "P".  Available palettes are :data:`Palette.WEB` or
           :data:`Palette.ADAPTIVE`.
        :param colors: Number of colors to use for the :data:`Palette.ADAPTIVE`
           palette. Defaults to 256.
        :rtype: :py:class:`~PIL.Image.Image`
        :returns: An :py:class:`~PIL.Image.Image` object.
        r]rprqrr)rnrqzillegal conversionr+c	��|d|dz|d|dzz|d|dzz|ddzz}tdtdt|���S)Nrr	r*r+rE�)rI�minrc)re�vs  r�convert_transparencyz+Image.convert.<locals>.convert_transparency�sZ���!��q��t��a��d�Q�q�T�k�1�A�a�D�1�Q�4�K�?�!�A�$��*�L�A��q�#�c�3�q�6�"2�3�3rrnc3�H�K�|]}��|dz|dzdz�����y�w)r,Nr)�.0�irt�matrixr]s  ���r�	<genexpr>z Image.convert.<locals>.<genexpr>�s3�����)��-�V�A��E�A��E�A�I�-F��U�)�s�"rNF)rirnrm�rBrr)rnrqrpzVPalette images with Transparency expressed in bytes should be converted to RGBA imagesT�r	r	z2Couldn't allocate a palette color for transparencyz$cannot allocate more than 256 colorsr��rBr�rrz.Transparency for P mode should be bytes or intr	r�z0Couldn't allocate palette entry for transparencyro)rqrrrs)�ImageCms�sRGB)+rr�r_r�r�r�r$�convert_matrixr�rcrbr��range�quantize�convert_transparentr��bytesr9r:r�rC�getcolor�str�putpixel�convert�getpixelrercrdrOrQr�r�rr�r}�
createProfile�buildTransform�applyrIrMrzr�)r�r_rx�ditherr��colors�has_transparencyr�r$�new_im�trns�delete_trnsr&�trns_im�errr�r��
other_moder}�srgb�lab�profiles�	transform�modebasertr]s  `                     @@rr�z
Image.convertjsf���`	
�	�	��)�T�Y�Y�6����	�	�S�(��|�|��|�|�(�(�����u�}�!1������	�	�)�&��9�9�;����<�'�*�� ��o�%����'�'��f�5�B��Y�Y�r�]�F��D�G�G�M�M�Q�$6�%�{�{�>�:��4��3�;�#7���#M�L���Y�!�^�#(�)�!&�q�#�l�*;�!<�)�$�L�/;����N�+��M��3�;�4�9�9��.��=�=��(�(�������	�	�_�,���1G��	�	�U�"�t�v�~�����G�G�/�/��d�i�i��6O�P����K�K��/��
����/�/�D�<M�4M��I�I�n�-���a��'��M�M�3��#'�K�"�$�)�)�V�4�G��y�y�C�'��*�*�4�<�<�8�%�a��/�"V�C�A�$+�O�O�$<�$<�Q��$E���y�#���(�(���3��<�/�&-�o�o�d�&;�G�'.�o�o�e�&<�G�&�/�/��7�����c�!�d�.B�&B��I�I�n�-��"���a��'��G�G�,�,�Q�/���3�'��G�G�+�+�A�q�1�J�C�$�S�/�)��3�;�7�g�&6�&6�6����!�!�&�)�B��Y�Y�r�]�F�&�)�6�6��v�y�y�+�+�E�2��F�N���K�K��/���V�28�.�.�2I�2I�$�PV�2W�F�K�K��/��M�6�M��T�Y�Y��%�%�!%���e�!3�����J��4�4�&��-�-�f�5���,�,�U�3��*.�)�)�u�*<�C��;�4��+��$�3�3��Q�K��!��d�i�i���	�!���t�,�,��>��*�*�F�	-�������v�.�B����2����3�;�7�g�&6�&6�6�&�)�6�6�u�b�m�m�E�>R�S�F�N�����N�+����{�{�c�!�	�28�.�.�2I�2I�$�PV�2W�F�K�K��/��
�/3����N�+��
��W$.�A�#&�q�6�-S�#S�)-�A�*4�S�/�q�$@�%&��	A��^!�V����N�3��M�M�"T�U��M�V��4�
	-�	
-�&�t�y�y�1���t�y�y�(���W�W�_�_�X�.���Z�Z��f�-����
-�*�� ��o�1�,��
-���
	-��0"�����N�3��1�v�!G�G�!�
�
�N���
�
���sy�>V3�)W'�%X�7)Z�3	W$�<W�W$�'+X�X�	Z�#AY6�5Z�6	Z�?Z
�
Z�Z�Z�	[ �%0[�[ rc�d�|j�|�/tj}|jdk(rtj}|jdk(r/|tjtj
fvr
d}t
|��|r�|j�|jdk7r
d}t
|��|jdvr
d}t
|��|jjd||j�}|j|�}|jj�|_
|S|j|jj|||��}dd	l
m}	|jj�}
|jj!|
|
�d|t#|
�z}|	j|
|�|_
|S)
a
        Convert the image to 'P' mode with the specified number
        of colors.

        :param colors: The desired number of colors, <= 256
        :param method: :data:`Quantize.MEDIANCUT` (median cut),
                       :data:`Quantize.MAXCOVERAGE` (maximum coverage),
                       :data:`Quantize.FASTOCTREE` (fast octree),
                       :data:`Quantize.LIBIMAGEQUANT` (libimagequant; check support
                       using :py:func:`PIL.features.check_feature` with
                       ``feature="libimagequant"``).

                       By default, :data:`Quantize.MEDIANCUT` will be used.

                       The exception to this is RGBA images. :data:`Quantize.MEDIANCUT`
                       and :data:`Quantize.MAXCOVERAGE` do not support RGBA images, so
                       :data:`Quantize.FASTOCTREE` is used by default instead.
        :param kmeans: Integer
        :param palette: Quantize to the palette of given
                        :py:class:`PIL.Image.Image`.
        :param dither: Dithering method, used when converting from
           mode "RGB" to "P" or from "RGB" or "L" to "1".
           Available methods are :data:`Dither.NONE` or :data:`Dither.FLOYDSTEINBERG`
           (default).
        :returns: A new image
        NrrzoFast Octree (method == 2) and libimagequant (method == 3) are the only valid methods for quantizing RGBA imagesrpzbad mode for palette image>rnrqz7only RGB or L mode images can be quantized to a paletter	r�)rrSrTr_rVrWr�r$r�r�r�r�r�r�r��getpalettemoderrb)r�r��method�kmeansr�r�r�r$r�r�r_s           rr�zImage.quantizeQsn��F	
�	�	���>��'�'�F��y�y�F�"�!�,�,���9�9���6�����"�"�2
�$
�H�
��S�/�!���L�L�N��|�|�s�"�2�� ��o�%��y�y��,�O�� ��o�%�������f�g�j�j�9�B��Y�Y�r�]�F�$�_�_�1�1�3�F�N��M�
�Y�Y�t�w�w�'�'����?�
@��"��u�u�#�#�%���%�%�"�"�4��.�/C��#�d�)�1C�D��!�.�.�t�W�=��
��	rc�t�|j�|j|jj��S)z�
        Copies this image. Use this method if you wish to paste things
        into an image, but still retain the original.

        :rtype: :py:class:`~PIL.Image.Image`
        :returns: An :py:class:`~PIL.Image.Image` object.
        )rr�r$r�r�s rr�z
Image.copy�s&��	
�	�	���y�y�������(�(rc��|�|j�S|d|dkr
d}t|��|d|dkr
d}t|��|j�|j|j	|j
|��S)a�
        Returns a rectangular region from this image. The box is a
        4-tuple defining the left, upper, right, and lower pixel
        coordinate. See :ref:`coordinate-system`.

        Note: Prior to Pillow 3.4.0, this was a lazy operation.

        :param box: The crop rectangle, as a (left, upper, right, lower)-tuple.
        :rtype: :py:class:`~PIL.Image.Image`
        :returns: An :py:class:`~PIL.Image.Image` object.
        r*rz&Coordinate 'right' is less than 'left'r+r	z'Coordinate 'lower' is less than 'upper')r�r�rr��_cropr$)r��boxr�s   r�cropz
Image.crop�sx���;��9�9�;���q�6�C��F�?�:�C��S�/�!�
��V�c�!�f�_�;�C��S�/�!��	�	���y�y����D�G�G�S�1�2�2rc��tttt|��\}}}}t||z
�t||z
�f}t	|�|j||||f�S)a]
        Returns a rectangular region from the core image object im.

        This is equivalent to calling im.crop((x0, y0, x1, y1)), but
        includes additional sanity checks.

        :param im: a core image object
        :param box: The crop rectangle, as a (left, upper, right, lower)-tuple.
        :returns: A core image object.
        )r�rc�round�abs�_decompression_bomb_checkr�)r�r$r��x0�y0�x1�y1�absolute_valuess        rr�zImage._crop�sX���S�#�e�S�/�2���B��B��r�B�w�<��R�"�W��6��!�/�2��w�w��B��B�'�(�(rc��y)aY
        Configures the image file loader so it returns a version of the
        image that as closely as possible matches the given mode and
        size. For example, you can use this method to convert a color
        JPEG to grayscale while loading it.

        If any changes are made, returns a tuple with the chosen ``mode`` and
        ``box`` with coordinates of the original image within the altered one.

        Note that this method modifies the :py:class:`~PIL.Image.Image` object
        in place. If the image has already been loaded, this method has no
        effect.

        Note: This method is not implemented for most images. It is
        currently implemented only for JPEG and MPO images.

        :param mode: The requested mode.
        :param size: The requested size in pixels, as a 2-tuple:
           (width, height).
        Nr)r�r_r�s   r�draftzImage.draft�s��*	
rc��|�|}|j�|j|jj||��Sr�)rr�r$�expand)r��xmargin�ymargins   r�_expandz
Image._expand�s3���?��G��	�	���y�y��������9�:�:rc
�@�ddlm}|j�t|t�r|�}t|d�s
d}t
|��t||j�}|jjdk(s|r*|j|j|j��St|jj�D�cgc];}|j|j|jj|�����=}}t|j|�Scc}w)z�
        Filters this image using the given filter.  For a list of
        available filters, see the :py:mod:`~PIL.ImageFilter` module.

        :param filter: Filter kernel.
        :returns: An :py:class:`~PIL.Image.Image` object.r	)�ImageFilter�filterz>filter argument should be ImageFilter.Filter instance or class)r�r�rr�rr%�	TypeError�MultibandFilterr$rcr�r�r��getband�merger_)r�r�r�r��	multiband�c�imss       rr�zImage.filter�s���	"��	�	���f�h�'��X�F��v�x�(�R�C��C�.� ��v�{�'B�'B�C�	��7�7�=�=�A����9�9�V�]�]�4�7�7�3�4�4�CH����
�
�BV�
�=>�D�I�I�f�m�m�D�G�G�O�O�A�$6�7�8�
��
��T�Y�Y��$�$��
s�ADc�T�tj|j�jS)z�
        Returns a tuple containing the name of each band in this image.
        For example, ``getbands`` on an RGB image returns ("R", "G", "B").

        :returns: A tuple containing band names.
        :rtype: tuple
        )rr^r_rcr�s r�getbandszImage.getbandss��� � ����+�1�1�1r)�
alpha_onlyc�X�|j�|jj|�S)aG
        Calculates the bounding box of the non-zero regions in the
        image.

        :param alpha_only: Optional flag, defaulting to ``True``.
           If ``True`` and the image has an alpha channel, trim transparent pixels.
           Otherwise, trim pixels when all channels are zero.
           Keyword-only argument.
        :returns: The bounding box is returned as a 4-tuple defining the
           left, upper, right, and lower pixel coordinate. See
           :ref:`coordinate-system`. If the image is completely empty, this
           method returns None.

        )rr$�getbbox)r�r�s  rr�z
Image.getbboxs �� 	
�	�	���w�w���z�*�*rc��|j�|jdvrN|jj�}t	d�D�cgc]}||s�	|||f��}}t|�|kDry|S|jj
|�Scc}w)a�
        Returns a list of colors used in this image.

        The colors will be in the image's mode. For example, an RGB image will
        return a tuple of (red, green, blue) color values, and a P image will
        return the index of the color in the palette.

        :param maxcolors: Maximum number of colors.  If this number is
           exceeded, this method returns None.  The default limit is
           256 colors.
        :returns: An unsorted list of (count, pixel) values.
        )rirnrprnN)rr_r$�	histogramr�rb�	getcolors)r��	maxcolors�hrw�outs     rr�zImage.getcolors/s~��	
�	�	���9�9��'����!�!�#�A�&+�C�j�9��A�a�D�A�a�D�!�9�9�C�9��3�x�)�#���J��w�w� � ��+�+��	:s�
B�	Bc�t�|j�|�|jj|�S|jS)a�
        Returns the contents of this image as a sequence object
        containing pixel values.  The sequence object is flattened, so
        that values for line one follow directly after the values of
        line zero, and so on.

        Note that the sequence object returned by this method is an
        internal PIL data type, which only supports certain sequence
        operations.  To convert it to an ordinary sequence (e.g. for
        printing), use ``list(im.getdata())``.

        :param band: What band to return.  The default is to return
           all bands.  To return a single band, pass in the index
           value (e.g. 0 to get the "R" band from an "RGB" image).
        :returns: A sequence-like object.
        )rr$r�)r��bands  rraz
Image.getdataFs/��$	
�	�	�����7�7�?�?�4�(�(��w�w�rc�����j��jjdkDr1t�fd�t	�jj�D��S�jj�S)a"
        Gets the minimum and maximum pixel values for each band in
        the image.

        :returns: For a single-band image, a 2-tuple containing the
           minimum and maximum pixel value.  For a multi-band image,
           a tuple containing one 2-tuple for each band.
        r	c3�p�K�|]-}�jj|�j����/y�wr�)r$r��
getextrema)rvrwr�s  �rryz#Image.getextrema.<locals>.<genexpr>is'�����W�Q�������+�6�6�8�W�s�36)rr$rcr�r�r�r�s`rr�zImage.getextrema]sO���	
�	�	���7�7�=�=�1���W�%����
�
�BV�W�W�W��w�w�!�!�#�#rc����d����fd��t�tjd�iStj|�}�|j��|�iS)Nc�0�tjdd|�S)Nz^{[^}]+}r�)�re�sub)�tags r�get_namezImage._getxmp.<locals>.get_namems���6�6�*�b�#�.�.rc���|jj�D��cic]\}}�|�|��}}}t|�}|r]|D]V}�|j�}�	|�}||vr1t	||t�s	||g||<||j|��R|||<�X|S|r|jr|j|d<|S|jScc}}w)Nr)�attrib�items�listr�r�rKr)
�element�krs�value�children�childrV�child_valuer��	get_values
        ��rr�z Image._getxmp.<locals>.get_valueps����07���0D�0D�0F�G���1�X�a�[�!�^�G�E�G��G�}�H��%�2�E�#�E�I�I�.�D�"+�E�"2�K��u�}�)�%��+�t�<�+0��;�-�E�$�K��d��*�*�;�7�&1��d��2��L���<�<�$+�L�L�E�&�M��L��|�|�#��!Hs�C
z5XMP data cannot be read without defusedxml dependency)rr9r:�
fromstringr�)r��xmp_tags�rootr�r�s   @@r�_getxmpz
Image._getxmplsO���	/�	�(���M�M�Q�R��I��)�)�(�3�D��T�X�X�&�	�$��8�8rc�.�|j�!t�|_d|j_n"|jjr|jSd|j_|jj	d�}|��d|jvrDt
j
dj|jdjd�dd��}n�t|d	�r�|jj|j_|jj|j_|jj|j |jj"�|�|jj%|�t&j(j*|jvrh|jj	d
�}|rKt-j.d|�}|r3t1|d�|jt&j(j*<|jS)
zj
        Gets EXIF data from the image.

        :returns: an :py:class:`~PIL.Image.Exif` object.
        NFT�exifzRaw profile type exifr�rTr+�tag_v2zXML:com.adobe.xmpztiff:Orientation(="|>)([0-9])r*)r��Exif�_loadedr��getr��fromhexrM�splitr%r��_bigtiff�bigtiff�_endian�endian�load_from_fpr��_offsetrr
�Base�Orientationr��searchrc)r��	exif_infor��matchs    r�getexifz
Image.getexif�s|���:�:����D�J�!&�D�J�J��
�Z�Z�
�
��:�:��!��
�
���I�I�M�M�&�)�	���&�$�)�)�3�!�M�M��G�G�D�I�I�&=�>�D�D�T�J�1�2�N�O��	���x�(�%)�[�[�%9�%9��
�
�"�$(�K�K�$7�$7��
�
�!��
�
�'�'�������1D�1D�E�� ��J�J�O�O�I�&��=�=�$�$�D�J�J�6��y�y�}�}�%8�9�H���	�	�"B�H�M���<?��a��M�D�J�J�x�}�}�8�8�9��z�z�rc��|j�|jjsyd|j_|j�y)NF)r�r�r�r�s r�_reload_exifzImage._reload_exif�s0���:�:��T�Z�Z�%7�%7��"��
�
�����rc�Z�g}|j�}g}tjj|vr[|tjj}|r<t	|t
�s|f}|D]$}|j
|j|�|f��&|jtjj�}|r8|jd�r'|j
||jjf�d}|D]�\}}	|jj�}
|�|
}|j}|jd�}|�j	||j z
}|jj%|�|jj'|jd��}
t)j*|
�}t-|�5}|�|	g|_|j1d�|j3�|j
|�ddd���|�|jj%|�|S#t"$rY��wxYw#1swY��7xYw)Niir)r�r
r��SubIFDsr�r�rK�
_get_ifd_dict�get_ifd�IFD�IFD1r��_info�nextr��tell�_exif_offsetr��seek�readr!r"�open�
_frame_pos�_seekr)r��child_imagesr��ifds�subifd_offsets�
subifd_offset�ifd1r��ifd�
ifd_offset�current_offsetr��thumbnail_offsetr3r$s               r�get_child_imageszImage.get_child_images�s������|�|�~�����=�=� � �D�(�!�(�-�-�"7�"7�8�N��!�.�%�8�&4�%6�N�%3�T�M��K�K��!3�!3�M�!B�M� R�S�T��|�|�H�L�L�-�-�.���D�H�H�S�M��K�K��t�z�z���/�0���#�	(�O�C��!�W�W�\�\�^�N��~�'�����B�"�w�w�s�|���+��$��(9�(9�9�$������-�.��w�w�|�|�C�G�G�C�L�1���Z�Z��%���b��
(�R�#�+�%/�L�B�M��H�H�Q�K����	��#�#�B�'�
(�
(�!	(�.���G�G�L�L�� ����&�����
(�
(�s�7H�+=H �	H�H� H*	c�N�|j�|jjS)zr
        Returns a capsule that points to the internal image memory.

        :returns: A capsule object.
        )rr$�ptrr�s r�getimzImage.getim�s��	
�	�	���w�w�{�{�rc���|j�	|jj�}|�|}t	|jj||��S#t$rYywxYw)aG
        Returns the image palette as a list.

        :param rawmode: The mode in which to return the palette. ``None`` will
           return the palette in its current mode.

           .. versionadded:: 9.1.0

        :returns: A list of color values [r, g, b, ...], or None if the
           image has no palette.
        N)rr$r�r�r�r)r�rbr_s   rrzImage.getpalette�s`��	
�	�	��	��7�7�)�)�+�D��?��G��D�G�G�&�&�t�W�5�6�6��	�	��	�s�A�	A!� A!c��|jdvxsF|jdk(xr%|jjjd�xsd|jvS)aN
        Determine if an image has transparency data, whether in the form of an
        alpha channel, a palette with an alpha channel, or a "transparency" key
        in the info dictionary.

        Note the image might still appear solid, if all of the values shown
        within are opaque.

        :returns: A boolean.
        )rB�Lar�rr�RGBarp�Ar])r_r�r
r�r�s r�has_transparency_datazImage.has_transparency_datasR��
�I�I�;�;�
+��	�	�S� �D�T�\�\�%6�%6�%?�%?��%D�
+�����*�	
rc�|�|jdk7sd|jvryddlm}|j	d�}|jd}t|t�rt|�D]\}}|||dzdz<�nd	||dzdz<|jdt
|��|_d|j_	|jd=y)
z�
        If a P mode image has a "transparency" key in the info dictionary,
        remove the key and instead apply the transparency to the palette.
        Otherwise, the image is unchanged.
        rpr]Nr	r�rrr,r+r)
r_r�r�r�rr�r��	enumerater�r`)r�r�r�r]rw�alphas      r�apply_transparencyzImage.apply_transparencys����9�9���~�T�Y�Y�>��"��/�/�&�)���y�y��0���l�E�*�%�l�3�
+���5�%*���A���	�"�
+�-.�G�L�1�$�q�(�)�#�0�0���w��H���������I�I�n�%rc��|j�|jr|jj|�S|jjt	|��S)a

        Returns the pixel value at a given position.

        :param xy: The coordinate, given as (x, y). See
           :ref:`coordinate-system`.
        :returns: The pixel value.  If the image is a multi-layer image,
           this method returns a tuple.
        )rr�r�r$r�)r��xys  rr�zImage.getpixel)sB��	
�	�	���=�=��=�=�)�)�"�-�-��w�w����b�	�*�*rc��|j�|jj�\}}t|�t|�fS)z�
        Get projection to x and y axes

        :returns: Two sequences, indicating where there are non-zero
            pixels along the X-axis and the Y-axis, respectively.
        )rr$�
getprojectionr�)r��x�ys   rr!zImage.getprojection8s6��	
�	�	���w�w�$�$�&���1��A�w��Q���rc�<�|j�|r6|j�|jjd|j�S|jdvr-|�|j	�}|jj|�S|jj�S)a�
        Returns a histogram for the image. The histogram is returned as a
        list of pixel counts, one for each pixel value in the source
        image. Counts are grouped into 256 bins for each band, even if
        the image has more than 8 bits per band. If the image has more
        than one band, the histograms for all bands are concatenated (for
        example, the histogram for an "RGB" image contains 768 values).

        A bilevel image (mode "1") is treated as a grayscale ("L") image
        by this method.

        If a mask is provided, the method returns a histogram for those
        parts of the image where the mask image is non-zero. The mask
        image must have the same size as the image, and be either a
        bi-level image (mode "1") or a grayscale image ("L").

        :param mask: An optional mask.
        :param extrema: An optional tuple of manually-specified extrema.
        :returns: A list containing pixel counts.
        r��rmrk)rr$r�r_r��r��mask�extremas   rr�zImage.histogramDsy��*	
�	�	����I�I�K��7�7�$�$�V�T�W�W�5�5��9�9�
�"����/�/�+���7�7�$�$�W�-�-��w�w� � �"�"rc�<�|j�|r6|j�|jjd|j�S|jdvr-|�|j	�}|jj|�S|jj�S)ah
        Calculates and returns the entropy for the image.

        A bilevel image (mode "1") is treated as a grayscale ("L")
        image by this method.

        If a mask is provided, the method employs the histogram for
        those parts of the image where the mask image is non-zero.
        The mask image must have the same size as the image, and be
        either a bi-level image (mode "1") or a grayscale image ("L").

        :param mask: An optional mask.
        :param extrema: An optional tuple of manually-specified extrema.
        :returns: A float value representing the image entropy
        r�r%)rr$�entropyr_r�r&s   rr*z
Image.entropycss�� 	
�	�	����I�I�K��7�7�?�?�6�4�7�7�3�3��9�9�
�"����/�/�+���7�7�?�?�7�+�+��w�w��� � rc��t|�r|�|}d}|�d}t|�dk(rVt|�r
|j}n%t|�r
|j}n
d}t|��||d|dz|d|dzfz
}t	|t
�r#ddlm}|j||j�}nxt|�rm|j�|j|jk7r8|jdk7s|jd	vr|j|j�}|j}|j�|r8|j�|jj|||j�y|jj||�y)
a�
        Pastes another image into this image. The box argument is either
        a 2-tuple giving the upper left corner, a 4-tuple defining the
        left, upper, right, and lower pixel coordinate, or None (same as
        (0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size
        of the pasted image must match the size of the region.

        If the modes don't match, the pasted image is converted to the mode of
        this image (see the :py:meth:`~PIL.Image.Image.convert` method for
        details).

        Instead of an image, the source can be a integer or tuple
        containing pixel values.  The method then fills the region
        with the given color.  When creating RGB images, you can
        also use color strings as supported by the ImageColor module.

        If a mask is given, this method updates only the regions
        indicated by the mask. You can use either "1", "L", "LA", "RGBA"
        or "RGBa" images (if present, the alpha band is used as mask).
        Where the mask is 255, the given image is copied as is.  Where
        the mask is 0, the current value is preserved.  Intermediate
        values will mix the two images together, including their alpha
        channels if they have them.

        See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to
        combine images with respect to their alpha channels.

        :param im: Source image or pixel value (integer or tuple).
        :param box: An optional 4-tuple giving the region to paste into.
           If a 2-tuple is used instead, it's treated as the upper left
           corner.  If omitted or None, the source is pasted into the
           upper left corner.

           If an image is given as the second argument and there is no
           third, the box defaults to (0, 0), and the second argument
           is interpreted as a mask image.
        :param mask: An optional mask image.
        Nr�r*z,cannot determine region size; use 4-item boxrr	��
ImageColorrq)rBrrr)r'rbr�r�r�r�r�r-r�r_rr�r$r�paste)r�r$r�r'r�r�r-s       rr.zImage.paste}sD��P�s�����D��C��;��C��s�8�q�=��2���w�w���T�"��y�y��E�� ��o�%��C��F�T�!�W�$�c�!�f�t�A�w�&6�7�7�C��b�#��$��$�$�R����3�B�
��_��G�G�I��y�y�B�G�G�#��9�9��%����8N�)N����D�I�I�.�B����B�������I�I�K��G�G�M�M�"�c�4�7�7�+��G�G�M�M�"�c�"rc��t|ttf�s
d}t|��t|ttf�s
d}t|��t	|�dvr
d}t|��t	|�dk(s
d}t|��t|�dkr
d}t|��t	|�dk(r||jz}|d	|jzk(r|}n|j|�}||d|jz|d
|jzfz}|d	|jzk(r|}n|j|�}t||�}|j||�y)a-'In-place' analog of Image.alpha_composite. Composites an image
        onto this image.

        :param im: image to composite over this one
        :param dest: Optional 2 tuple (left, top) specifying the upper
          left corner in this (destination) image.
        :param source: Optional 2 (left, top) tuple for the upper left
          corner in the overlay source image, or 4 tuple (left, top, right,
          bottom) for the bounds of the source rectangle

        Performance Note: Not currently implemented in-place in the core layer.
        zSource must be a tuplezDestination must be a tuple)r*r,zSource must be a 2 or 4-tupler*zDestination must be a 2-tuplerzSource must be non-negativer�r	N)r�r�r�r�rbrrr�r�rar`�alpha_compositer.)	r�r$�dest�sourcer��overlayr��
background�results	         rr0zImage.alpha_composite�s6���&�4��-�0�*�C��S�/�!��$��u�
�.�/�C��S�/�!��v�;�f�$�1�C��S�/�!��4�y�A�~�1�C��S�/�!��v�;��?�/�C��S�/�!��v�;�!���b�g�g�%�F��V�b�g�g�%�%��G��g�g�f�o�G��d�1�g��
�
�-�t�A�w����/G�H�H���&�4�9�9�$�$��J����3��J� ��W�5���
�
�6�3�rc�P�|j�t|t�r|j|�St	|�r}|j
dvr9t
|�\}}|j|jj||��Std�D�cgc]
}||���c}|jjz}|j
dk(r
d}t|��|dk7r|D�cgc]
}t|���}}|j|jj||��Scc}wcc}w)a�
        Maps this image through a lookup table or function.

        :param lut: A lookup table, containing 256 (or 65536 if
           self.mode=="I" and mode == "L") values per band in the
           image.  A function can be used instead, it should take a
           single argument. The function is called once for each
           possible pixel value, and the resulting table is applied to
           all bands of the image.

           It may also be an :py:class:`~PIL.Image.ImagePointHandler`
           object::

               class Example(Image.ImagePointHandler):
                 def point(self, data):
                   # Return result
        :param mode: Output mode (default is same as input).  In the
           current version, this can only be used if the source image
           has mode "L" or "P", and the output has mode "1" or the
           source image mode is "I" and the output mode is "L".
        :returns: An :py:class:`~PIL.Image.Image` object.
        )rmrurkrnrkz+point operation not supported for this mode)rr��ImagePointHandler�point�callabler_r�r�r$�point_transformr�rcr�r�)r��lutr_r�r�rwr�s       rr8zImage.points���0	
�	�	���c�,�-��9�9�T�?�"��C�=��y�y�.�.�!0�� 4�
��v��y�y����!8�!8���!G�H�H�#(��:�.�a�3�q�6�.������>�C��9�9���?�C��S�/�!��3�;�%(�)��5��8�)�C�)��y�y������s�D�1�2�2��/��*s�D�D#c��|j�|jdvrW	t|j�dz}	|jj	|�d|_|jj|_	|jdvrd}nd}t|�rL|jd	vr
d}t
|��|j�|jd
k(r0|jd�}n	|jj||�y|jj!|j|�y#t
tf$rI}|jj|�}|jdvrd}t
|�|�||_Yd}~��$d}~wwxYw#t$r}d}t
|�|�d}~wwxYw#t
tf$rtd|j|�}Y��wxYw)az
        Adds or replaces the alpha layer in this image.  If the image
        does not have an alpha layer, it's converted to "LA" or "RGBA".
        The new layer must be either "L" or "1".

        :param alpha: The new alpha layer.  This can either be an "L" or "1"
           image having the same size as this image, or an integer or
           other color value.
        r|rz alpha channel could not be addedN�illegal image moder^r	r+)rirnrirn)rr_rzr$�setmoder�r�r�r�r�r�r'r�fillbandr�r��putband)r�rr_r�r$r�r�s       r�putalphazImage.putalpha2s���	
�����9�9�0�0�
-�"�4�9�9�-��3��!��G�G�O�O�D�)�!%��
�!�W�W�\�\��
�
�9�9��$��D��D��u���z�z��+�*�� ��o�%��J�J�L��z�z�S� ��
�
�c�*��
���� � ��u�-�
���������$�'��I'�
�3�!�������.�B��w�w�&:�:�@��(��o�1�4� �D�G�G��
!���
-�*�� ��o�1�,��
-��*#�J�/�
3��C����E�2��
3�sR�F�D%�"F�!F�%E=�4>E8�2F�8E=�=F�	F�	F�F�&G�Gc�^�|j�|jj|||�y)a|
        Copies pixel data from a flattened sequence object into the image. The
        values should start at the upper left corner (0, 0), continue to the
        end of the line, followed directly by the first value of the second
        line, and so on. Data will be read until either the image or the
        sequence ends. The scale and offset values are used to adjust the
        sequence values: **pixel = value*scale + offset**.

        :param data: A flattened sequence object.
        :param scale: An optional scale value.  The default is 1.0.
        :param offset: An optional offset value.  The default is 0.0.
        N)rr$�putdata)r�r3r�r�s    rrCz
Image.putdataks$��	
����������e�V�,rc��ddlm}|jdvr
d}t|��t	||j�r'|j|j|j�}n-t	|t�st|�}|j||�}d|jvrdnd|_	||_d|j_|j�y	)
a}
        Attaches a palette to this image.  The image must be a "P", "PA", "L"
        or "LA" image.

        The palette sequence must contain at most 256 colors, made up of one
        integer value for each channel in the raw mode.
        For example, if the raw mode is "RGB", then it can contain at most 768
        values, made up of red, green and blue values for the corresponding pixel
        index in the 256 colors.
        If the raw mode is "RGBA", then it can contain at most 1024 values,
        containing red, green, blue and alpha values.

        Alternatively, an 8-bit string may be used instead of an integer sequence.

        :param data: A palette sequence (either a list or a string).
        :param rawmode: The raw mode of the palette. Either "RGB", "RGBA", or a mode
           that can be transformed to "RGB" or "RGBA" (e.g. "R", "BGR;15", "RGBA;L").
        r	r�rAr=rr�rprqN)r�r�r_r�r�r2rbr�r�r�r)r�r3rbr�r�r�s      rrCzImage.putpalette}s���&	#��9�9�2�2�&�C��S�/�!��d�L�5�5�6�"�&�&�t�|�|�T�\�\�B�G��d�E�*��T�{��"�&�&�w��5�G� �D�I�I�-�T�3��
����!������	�	�rc���|jr|j�|j�|jr|jj	||�S|j
dvr{t
|ttf�ret|�dvrX|j
dk(rt|�dk(r|dnd}|dd}|jj||�}|j
dk(r|f}|jj	||�S)a�
        Modifies the pixel at the given position. The color is given as
        a single numerical value for single-band images, and a tuple for
        multi-band images. In addition to this, RGB and RGBA tuples are
        accepted for P and PA images.

        Note that this method is relatively slow.  For more extensive changes,
        use :py:meth:`~PIL.Image.Image.paste` or the :py:mod:`~PIL.ImageDraw`
        module instead.

        See:

        * :py:meth:`~PIL.Image.Image.paste`
        * :py:meth:`~PIL.Image.Image.putdata`
        * :py:mod:`~PIL.ImageDraw`

        :param xy: The pixel coordinate, given as (x, y). See
           :ref:`coordinate-system`.
        :param value: The pixel value.
        r��r+r,r�r,r+rqN)
r�rrr�r�r_r�r�r�rbr�r�r$)r�rr�rs    rr�zImage.putpixel�s���,�=�=��J�J�L��	�	���=�=��=�=�)�)�"�e�4�4�
�I�I��$��5�4��-�0��E�
�f�$��y�y�D� �$'��J�!�O��a�����b�q�	���L�L�)�)�%��6�E��y�y�D� ������w�w����E�*�*rc���ddlm}|jdvr
d}t|��d}d}|�x|jdk(rN|j	�|j
j
�}|dk(rd	}|j
j||�}ntd
�td�D��}d}d
gdz}t|�D]\}	}
|||
|z|
|z|zz
}|	||
<�t|�}|j�}d|_|j|||z��|_
|j
j|dz|jj��|j!d�}|j||�|j||��|_
d|j"vr.	|j%|j"d�|j"d<|S|S#t$rd|j"vr
|j"d=Y|SwxYw)ae
        Rewrites the image to reorder the palette.

        :param dest_map: A list of indexes into the original palette.
           e.g. ``[1,0]`` would swap a two item palette, and ``list(range(256))``
           is the identity transform.
        :param source_palette: Bytes or None.
        :returns:  An :py:class:`~PIL.Image.Image` object.

        r	r�)rnrpr=r+rqrprrr,c3�&K�|]	}|dz���y�w)r+Nr)rvrws  rryz&Image.remap_palette.<locals>.<genexpr>�s����*F�a�1��6�*F�s�irrrn)r�z;Lrnr])r�r�r_r�rr$r�r�	bytearrayr�rr�r�r�rCrr�r��index)
r��dest_map�source_paletter�r�rcrk�
palette_bytes�
new_positionsrw�oldPosition�mapping_palette�m_ims
             r�
remap_palettezImage.remap_palette�s���	#��9�9�J�&�&�C��S�/�!������!��y�y�C���	�	��#�w�w�5�5�7���6�)��E�!%���!3�!3�L�,�!O��!*�*F�5��:�*F�!F���
���c�	�
�(��1�	+�N�A�{��^��e�#�k�E�&9�E�&A��
�M�*+�M�+�&�		+�0$�M�2���y�y�{����
�#�0�0��/�E�"9�1�
���	
�����<�$�.����0D�0D�0F�G��|�|�C� �����
�|�4�#�0�0��}�0�U����T�Y�Y�&�
2�,4�N�N�4�9�9�^�;T�,U��	�	�.�)�
��t���	�
2�!�T�Y�Y�.��	�	�.�1����	
2�s�+F>�>$G&�%G&c
��t|dz
}|d|dz
|dz}|d|dz
|dz}||z}||z}tdt|d|z
��tdt|d|z
��t|jdtj|d|z��t|jdtj|d|z��fS)z�Expands the box so it includes adjacent pixels
        that may be used by resampling with the given resampling filter.
        rEr*rr+r	)�_filters_supportrIrcrrr��math�ceil)	r�r��resampler��filter_support�scale_x�scale_y�	support_x�	support_ys	         r�
_get_safe_boxzImage._get_safe_box s���*�(�3�c�9���q�6�C��F�?�d�1�g�-���q�6�C��F�?�d�1�g�-��"�W�,�	�"�W�,�	�
��3�s�1�v�	�)�*�+���3�s�1�v�	�)�*�+���	�	�!��d�i�i��A���(:�;�<���	�	�!��d�i�i��A���(:�;�<�	
�	
rc��|�2d|jv}|rtjntj}�n|tjtjtjtj
tjtjfvr�d|�d�}tjdftj
dftjdftjdftjd	ftjd
ffD�cgc]}|d�d|d
�d���}}|ddj|dd�zdz|dzz
}t|��|�|dkr
d}t|��t|�}|j�|�d|jz}nt|�}|j|k(r"|d|jzk(r|j�S|jdvrtj}|jdvrb|tjk7rO|jddd�|j�}	|	j|||�}	|	j|j�S|j�|��|tjk7r�t!|d|d
z
|d
z|z�xsd}
t!|d|dz
|dz|z�xsd}|
dkDs|dkDr�|j#|||�}|
|f}
t%|j&�r|j'|
|��}nt(j'||
|��}|d
|d
z
|
z|d|dz
|z|d|d
z
|
z|d|dz
|zf}|j+|j,j|||��Scc}w)aJ
        Returns a resized copy of this image.

        :param size: The requested size in pixels, as a 2-tuple:
           (width, height).
        :param resample: An optional resampling filter.  This can be
           one of :py:data:`Resampling.NEAREST`, :py:data:`Resampling.BOX`,
           :py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
           :py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
           If the image has mode "1" or "P", it is always set to
           :py:data:`Resampling.NEAREST`. If the image mode specifies a number
           of bits, such as "I;16", then the default filter is
           :py:data:`Resampling.NEAREST`. Otherwise, the default filter is
           :py:data:`Resampling.BICUBIC`. See: :ref:`concept-filters`.
        :param box: An optional 4-tuple of floats providing
           the source image region to be scaled.
           The values must be within (0, 0, width, height) rectangle.
           If omitted or None, the entire source is used.
        :param reducing_gap: Apply optimization by resizing the image
           in two steps. First, reducing the image by integer times
           using :py:meth:`~PIL.Image.Image.reduce`.
           Second, resizing using regular resampling. The last step
           changes size no less than by ``reducing_gap`` times.
           ``reducing_gap`` may be None (no first step is performed)
           or should be greater than 1.0. The bigger ``reducing_gap``,
           the closer the result to the fair resampling.
           The smaller ``reducing_gap``, the faster resizing.
           With ``reducing_gap`` greater or equal to 3.0, the result is
           indistinguishable from fair resampling in most cases.
           The default value is None (no optimization).
        :returns: An :py:class:`~PIL.Image.Image` object.
        N�;�Unknown resampling filter (�).�Image.Resampling.NEAREST�Image.Resampling.LANCZOS�Image.Resampling.BILINEAR�Image.Resampling.BICUBIC�Image.Resampling.BOX�Image.Resampling.HAMMINGr	� (r�)� Use �, ���� or rFz#reducing_gap must be 1.0 or greaterr��rirprzrrr*r+)r�)r_r>r?rCrArDr@rBrMr�r�rr�r�r��resizercr]r9�reducer�r�r$)r�r�rWr��reducing_gap�type_specialr�r��filtersr$�factor_x�factor_y�
reduce_box�factors              rrozImage.resize1sv��D���$�)�)�+�L�-9�z�)�)�z�?Q�?Q�H�
��������������N�N����

�
�0��z��<�C�
 �'�'�)C�D��'�'�)C�D��(�(�*E�F��'�'�)C�D��^�^�%;�<��'�'�)C�D�
�
���!�9�+�R��q�	�{�!�,�
�G�
�
�7�T�Y�Y�w�s��|�4�4�v�=����K�K�C��S�/�!��#��s�(:�7�C��S�/�!��T�{���	�	���;��4�9�9�$�C���*�C��9�9��������(:�!:��9�9�;���9�9�
�"�!�)�)�H��9�9��&�8�z�7I�7I�+I����T�6�:�4�9�9�E�F�B����4��3�/�B��:�:�d�i�i�(�(��	�	���#��J�4F�4F�(F��C��F�S��V�O�t�A�w�6��E�F�K�!�H��C��F�S��V�O�t�A�w�6��E�F�K�!�H��!�|�x�!�|�!�/�/��h��D�
�"�H�-���D�K�K�(��;�;�v�:�;�>�D� �<�<��f�*�<�E�D���V�j��m�+�x�7���V�j��m�+�x�7���V�j��m�+�x�7���V�j��m�+�x�7�	���y�y�������h��<�=�=��q
s�M>c���t|ttf�s||f}|�d|jz}nt|�}|dk(r"|d|jzk(r|j	�S|j
dvrN|j
ddd�|j
�}|j||�}|j
|j
�S|j�|j|jj||��S)a!
        Returns a copy of the image reduced ``factor`` times.
        If the size of the image is not dividable by ``factor``,
        the resulting size will be rounded up.

        :param factor: A greater than 0 integer or tuple of two integers
           for width and height separately.
        :param box: An optional 4-tuple of ints providing
           the source image region to be reduced.
           The values must be within ``(0, 0, width, height)`` rectangle.
           If omitted or ``None``, the entire source is used.
        r�r{rzrr)r�r�r�r�r�r_r�rprr�r$)r�rwr�r$s    rrpzImage.reduce�s����&�4��-�0��f�%�F��;��4�9�9�$�C���*�C��V���v��	�	�'9� 9��9�9�;���9�9��&����T�6�:�4�9�9�E�F�B����6�3�'�B��:�:�d�i�i�(�(��	�	���y�y��������4�5�5rc	�T�|dz}|s�|s�|dk(r|j�S|dk(r|jtj�S|dvrS|s|j|j
k(r8|j|dk(rtj�Stj�S|j\}}|�d}	n|}	|�|dz|dzf}
n|}
tj|�}ttj|�d�ttj|�d�d	ttj|�d�ttj|�d�d	g}d
�}||
d|	dz
|
d|	dz
|�\|d<|d
<|dxx|
dz
cc<|d
xx|
dz
cc<|r�g}
g}d|df||fd|ffD]4\}}||||�\}}|
j|�|j|��6tjt!|
��tj"t%|
��z
}tjt!|��tj"t%|��z
}|||z
dz||z
dz|�\|d<|d
<||}}|j'||ft(j*|||��S)a�
        Returns a rotated copy of this image.  This method returns a
        copy of this image, rotated the given number of degrees counter
        clockwise around its centre.

        :param angle: In degrees counter clockwise.
        :param resample: An optional resampling filter.  This can be
           one of :py:data:`Resampling.NEAREST` (use nearest neighbour),
           :py:data:`Resampling.BILINEAR` (linear interpolation in a 2x2
           environment), or :py:data:`Resampling.BICUBIC` (cubic spline
           interpolation in a 4x4 environment). If omitted, or if the image has
           mode "1" or "P", it is set to :py:data:`Resampling.NEAREST`.
           See :ref:`concept-filters`.
        :param expand: Optional expansion flag.  If true, expands the output
           image to make it large enough to hold the entire rotated image.
           If false or omitted, make the output image the same size as the
           input image.  Note that the expand flag assumes rotation around
           the center and no translation.
        :param center: Optional center of rotation (a 2-tuple).  Origin is
           the upper left corner.  Default is the center of the image.
        :param translate: An optional post-rotate translation (a 2-tuple).
        :param fillcolor: An optional color for area outside the rotated image.
        :returns: An :py:class:`~PIL.Image.Image` object.
        g�v@r�)�Zir{r�rG��c�L�|\}}}}}}||z||zz|z||z||zz|zfSr�r)	r"r#rxr�r&r�rZr�rs	         rr�zImage.rotate.<locals>.transform	sA��!'��Q��1�a��A��q�5�1�q�5�=�1�$�a�!�e�a�!�e�m�a�&7�7�7rr	r*r-)�	fillcolor)r��	transposer)r2rar`r1r3r�rU�radiansr��cos�sinrKrVrI�floorrrr�r7r8)r��anglerWr��center�	translater�wr��
post_trans�rotn_centerrxr��xx�yyr"r#�nw�nhs                   r�rotatezImage.rotate�s���D��
���)���z��y�y�{�"���|��~�~�i�&:�&:�;�;��	�!�v����t�{�{�1J��~�~�+0�B�;�I�'�'���<E�<P�<P���,�y�y���1����J�"�J��>��s�7�A��G�,�K� �K����e�$�$���$�(�(�5�/�2�&��$�(�(�5�/�2�&���4�8�8�E�?�"�B�'��$�(�(�5�/�2�&��

��	8� )�
��^�O�j��m�+�k�!�n�_�z�!�}�-L�f� 
���q�	�6�!�9�	�q�	�[��^�#�	��q�	�[��^�#�	���B��B��!�Q��!�Q��!�Q��8�
���1� ��A�v�.���1��	�	�!���	�	�!��
����3�r�7�#�d�j�j��R��&9�9�B����3�r�7�#�d�j�j��R��&9�9�B�
$-�r�A�v�Y��_��Q��i�#�o�v�#V� �F�1�I�v�a�y��r�q�A��~�~�
��F�I�$�$�f�h�)��
�	
rc���d}d}t|t�rt|�}d}n>t|�r|}d}n.|tj
k(r	tj
j}|s-t|d�r!t|j�r|j}|j�|jdd�}||_d|_
t�tj j#|�dj%�}|s|t&vr
t)�	t&|}|j/�t0vr
t)�|rt2|j/�}
nt0|j/�}
d}|r_tj j5|�}|j7d
d�rt9j:|d�}nt9j:|d�}	|
|||�|r|j?�y	y	#t$rY���wxYw#t*$r}d|��}	t-|	�|�d	}~wwxYw#t<$r<|r|j?�|r&	tj@|��#tB$rY�wxYw�wxYw)
a�
        Saves this image under the given filename.  If no format is
        specified, the format to use is determined from the filename
        extension, if possible.

        Keyword options can be used to provide additional instructions
        to the writer. If a writer doesn't recognise an option, it is
        silently ignored. The available options are described in the
        :doc:`image format documentation
        <../handbook/image-file-formats>` for each writer.

        You can use a file object instead of a filename. In this case,
        you must always specify the format. The file object must
        implement the ``seek``, ``tell``, and ``write``
        methods, and be opened in binary mode.

        :param fp: A filename (string), pathlib.Path object or file object.
        :param format: Optional format override.  If omitted, the
           format to use is determined from the filename extension.
           If a file object was used instead of a filename, this
           parameter should always be used.
        :param params: Extra parameters to the image writer.
        :returns: None
        :exception ValueError: If the output format could not be determined
           from the file name.  Use the format option to solve this.
        :exception OSError: If the file could not be written.  The file
           may have been created, and may contain partial data.
        r�FTrV�save_allrr	zunknown file extension: NrKzr+bzw+b)"r�rr�r�sys�stdout�bufferr�r%rVr�pop�encoderinfo�
encoderconfigr�r	�path�splitext�lower�	EXTENSIONr�r�r��upperr��SAVE_ALL�existsr��builtinsrr�r��remove�PermissionError)r�r�r��paramsr�open_fpr��extr�r��save_handler�createds            rrz
Image.save2	s"��<�����b�$���2�w�H��G�
�R�[��H��G�
�3�:�:�
�
��Z�Z�&�&���G�B��/�G�B�G�G�4D��w�w�H�	
�����:�:�j�%�0��!�������	��g�g���x�(��+�1�1�3����)�#���
-�"�3���
�<�<�>��%��F��#�F�L�L�N�3�L������/�L�����'�'�.�.��2�2�G��z�z�(�E�*��]�]�8�U�3���]�]�8�U�3��
	���r�8�,���H�H�J���m"�
��
��,�
-�0���6�� ��o�1�,��
-��.�	�����
����I�I�h�'�
��'�������	�sZ�G+�	G;�
H�+	G8�7G8�;	H�H�H�I"�;I�I"�	I�I"�I�I"c�(�|dk7r
d}t|��y)a0
        Seeks to the given frame in this sequence file. If you seek
        beyond the end of the sequence, the method raises an
        ``EOFError`` exception. When a sequence file is opened, the
        library automatically seeks to frame 0.

        See :py:meth:`~PIL.Image.Image.tell`.

        If defined, :attr:`~PIL.Image.Image.n_frames` refers to the
        number of available frames.

        :param frame: Frame number, starting at 0.
        :exception EOFError: If the call attempts to seek beyond the end
            of the sequence.
        rzno more images in fileN)�EOFError)r��framer�s   rrz
Image.seek�	s��$�A�:�*�C��3�-��rc��t||��y)a�
        Displays this image. This method is mainly intended for debugging purposes.

        This method calls :py:func:`PIL.ImageShow.show` internally. You can use
        :py:func:`PIL.ImageShow.register` to override its default behaviour.

        The image is first saved to a temporary file. By default, it will be in
        PNG format.

        On Unix, the image is then opened using the **xdg-open**, **display**,
        **gm**, **eog** or **xv** utility, depending on which one can be found.

        On macOS, the image is opened with the native Preview application.

        On Windows, the image is opened with the standard PNG display utility.

        :param title: Optional title to use for the image window, where possible.
        )�titleN)�_show)r�r�s  r�showz
Image.show�	s��(	�d�%� rc��|j�|jjdk(r|j�g}t|�St	|j
|jj
��}t|�S)a�
        Split this image into individual bands. This method returns a
        tuple of individual image bands from an image. For example,
        splitting an "RGB" image creates three new images each
        containing a copy of one of the original bands (red, green,
        blue).

        If you need only one band, :py:meth:`~PIL.Image.Image.getchannel`
        method can be more convenient and faster.

        :returns: A tuple containing bands.
        r	)rr$rcr�r�r�r�r�)r�r�s  rr�zImage.split�	s\��	
�	�	���7�7�=�=�A���9�9�;�-�C��S�z���d�i�i�������1�C��S�z�rc��|j�t|t�r 	|j�j	|�}|j
|jj|��S#t
$r}d|�d�}t|�|�d}~wwxYw)a@
        Returns an image containing a single channel of the source image.

        :param channel: What channel to return. Could be index
          (0 for "R" channel of "RGB") or channel name
          ("A" for alpha channel of "RGBA").
        :returns: An image in "L" mode.

        .. versionadded:: 4.3.0
        zThe image has no channel "�"N)	rr�r�r�rJr�r�r$r�)r��channelr�r�s    r�
getchannelzImage.getchannel�	s|��	
�	�	���g�s�#�
-��-�-�/�/�/��8��
�y�y�������1�2�2��	�
-�2�7�)�1�=�� ��o�1�,��
-�s�A+�+	B�4B�Bc��y)z�
        Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`.

        If defined, :attr:`~PIL.Image.Image.n_frames` refers to the
        number of available frames.

        :returns: Frame number, starting with 0.
        rrr�s rrz
Image.tell�	s��rrGc�����tttj|�����fd�}d}|�1|�}|�y�j	d|d|z|d|zf�}|�|d}|��j�|�}|�y�j|k7rH�j||||��}|j�_|�_	�jj�_d�_d�_
y)an
        Make this image into a thumbnail.  This method modifies the
        image to contain a thumbnail version of itself, no larger than
        the given size.  This method calculates an appropriate thumbnail
        size to preserve the aspect of the image, calls the
        :py:meth:`~PIL.Image.Image.draft` method to configure the file reader
        (where applicable), and finally resizes the image.

        Note that this function modifies the :py:class:`~PIL.Image.Image`
        object in place.  If you need to use the full resolution image as well,
        apply this method to a :py:meth:`~PIL.Image.Image.copy` of the original
        image.

        :param size: The requested size in pixels, as a 2-tuple:
           (width, height).
        :param resample: Optional resampling filter.  This can be one
           of :py:data:`Resampling.NEAREST`, :py:data:`Resampling.BOX`,
           :py:data:`Resampling.BILINEAR`, :py:data:`Resampling.HAMMING`,
           :py:data:`Resampling.BICUBIC` or :py:data:`Resampling.LANCZOS`.
           If omitted, it defaults to :py:data:`Resampling.BICUBIC`.
           (was :py:data:`Resampling.NEAREST` prior to version 2.5.0).
           See: :ref:`concept-filters`.
        :param reducing_gap: Apply optimization by resizing the image
           in two steps. First, reducing the image by integer times
           using :py:meth:`~PIL.Image.Image.reduce` or
           :py:meth:`~PIL.Image.Image.draft` for JPEG images.
           Second, resizing using regular resampling. The last step
           changes size no less than by ``reducing_gap`` times.
           ``reducing_gap`` may be None (no first step is performed)
           or should be greater than 1.0. The bigger ``reducing_gap``,
           the closer the result to the fair resampling.
           The smaller ``reducing_gap``, the faster resizing.
           With ``reducing_gap`` greater or equal to 3.0, the result is
           indistinguishable from fair resampling in most cases.
           The default value is 2.0 (very close to fair resampling
           while still being faster in many cases).
        :returns: None
        c�������d�}�\����jk\r��jk\ry�j�jz���z�k\r|��z��fd������fS|��z��fd������fS)Nc�~�tttj|�tj|�|��d�S)N��keyr	)rIrrrUr�rV)�numberr�s  r�round_aspectzDImage.thumbnail.<locals>.preserve_aspect_ratio.<locals>.round_aspect!
s+���3�t�z�z�&�1�4�9�9�V�3D�#�N�PQ�R�Rrc�&��t�|�zz
�Sr��r�)�n�aspectr#s ��r�<lambda>z@Image.thumbnail.<locals>.preserve_aspect_ratio.<locals>.<lambda>*
s���3�v��A��~�;N�rr�c�4��|dk(rdSt��|zz
�Sr�r�)r�r�r"s ��rr�z@Image.thumbnail.<locals>.preserve_aspect_ratio.<locals>.<lambda>-
s���1��6�a��s�6�A�PQ�E�>�?R�r)rar`)r�r�r"r#�
provided_sizer�s @@@��r�preserve_aspect_ratioz.Image.thumbnail.<locals>.preserve_aspect_ratio 
s����
S�!�D�A�q��D�J�J��1����#3���Z�Z�$�+�+�-�F��1�u��� ��V��1N�O��
�a�4�K�!���J�$R����a�4�KrNrr	)r�rq)r�r�rUr�r�rr�ror$r�r_r�r�r�)	r�r�rWrqr�r��resr$r�s	`       @r�	thumbnailzImage.thumbnail�	s����P�c�$�*�*�d�3�4�
�	�"���#�(�*�D��|���*�*�T�D��G�l�$:�D��G�l�<R�#S�T�C����!�f���;��I�I�K�)�*�D��|���9�9������T�8��<��P�B��e�e�D�G��D�J������D�J���
���
rr	c
�*�|jdvra|tjk7rN|jddd�|j�j	||||||�j|j�St|t�r|j	||||��St|d�r|j�\}}|�
d}t|��t|j||�}|jdk(r+|jr|jj�|_|jj�|_
|tjk(r2|D]+\}	}
|j!|	|tj"|
||du��-|S|j!d	|z|||||du�|S)
a�
        Transforms this image.  This method creates a new image with the
        given size, and the same mode as the original, and copies data
        to the new image using the given transform.

        :param size: The output size in pixels, as a 2-tuple:
           (width, height).
        :param method: The transformation method.  This is one of
          :py:data:`Transform.EXTENT` (cut out a rectangular subregion),
          :py:data:`Transform.AFFINE` (affine transform),
          :py:data:`Transform.PERSPECTIVE` (perspective transform),
          :py:data:`Transform.QUAD` (map a quadrilateral to a rectangle), or
          :py:data:`Transform.MESH` (map a number of source quadrilaterals
          in one operation).

          It may also be an :py:class:`~PIL.Image.ImageTransformHandler`
          object::

            class Example(Image.ImageTransformHandler):
                def transform(self, size, data, resample, fill=1):
                    # Return result

          It may also be an object with a ``method.getdata`` method
          that returns a tuple supplying new ``method`` and ``data`` values::

            class Example:
                def getdata(self):
                    method = Image.Transform.EXTENT
                    data = (0, 0, 100, 100)
                    return method, data
        :param data: Extra data to the transformation method.
        :param resample: Optional resampling filter.  It can be one of
           :py:data:`Resampling.NEAREST` (use nearest neighbour),
           :py:data:`Resampling.BILINEAR` (linear interpolation in a 2x2
           environment), or :py:data:`Resampling.BICUBIC` (cubic spline
           interpolation in a 4x4 environment). If omitted, or if the image
           has mode "1" or "P", it is set to :py:data:`Resampling.NEAREST`.
           See: :ref:`concept-filters`.
        :param fill: If ``method`` is an
          :py:class:`~PIL.Image.ImageTransformHandler` object, this is one of
          the arguments passed to it. Otherwise, it is unused.
        :param fillcolor: Optional fill color for the area outside the
           transform in the output image.
        :returns: An :py:class:`~PIL.Image.Image` object.
        rzrr)rW�fillraNzmissing method datarpr�)r_r>r?r�r�r��ImageTransformHandlerr%rar�r�r�r�r�r7r<�_Image__transformerr;)r�r�r�r3rWr�rr�r$r��quads           rr�zImage.transformN
su��n�9�9��&�8�z�7I�7I�+I����D�&�9�$�)�)�D�E���4���x��y�I������#�
��f�3�4��#�#�D�$���#�M�M��6�9�%�!�>�>�+�L�F�D��<�'�C��S�/�!�
����D�)�
,���9�9���������*�*�,�B�J��)�)�.�.�"����Y�^�^�#�!�
�	��T�� � ���y�~�~�t�X�y�D�?P��
��	�	
�����
�t�V�T�8�Y�$�=N�
��	rc
�z�|d|dz
}|d|dz
}|tjk(r|dd}n�|tjk(r0|\}	}
}}||	z
|z}
||
z
|z}tj}|
d|	d||
f}n�|tjk(r|dd}n�|tjk(r�|dd}|dd}|dd}|dd}|\}	}
d|z}d|z}|	|d|	z
|z|d|	z
|z|d|dz
|dz
|	z|z|z|
|d|
z
|z|d|
z
|z|d|dz
|dz
|
z|z|zf}n
d	}t|��|tjtjtjfvr�|tjtjtjfvr=tjd
tjdtjdi|d
|�d�z}nd|�d�}tjdftjdftjdffD�cgc]}|d�d
|d�d���}}|ddj|dd�zdz|dzz
}t|��|j�|j�|jdvrtj}|j j#||j ||||�ycc}w)Nr*rr+r	r.�r,rFzunknown transformation methodrfrgrcrhz) cannot be used.r`rarbrdrerirjrkrlrmrn)r7r8r9r:r;r�r>r?rArCr@rBrDrMrr_r$�
transform2)r�r��imager�r3rWr�r�r�r�r�r�r��xs�ysr��sw�se�ne�As�Atr�r�rss                        r�
__transformerzImage.__transformer�
s4��
��F�S��V�O����F�S��V�O���Y�%�%�%����8�D�
�y�'�'�
'�!�N�B��B���r�'�Q��B��r�'�Q��B��%�%�F���2�q�"�b�)�D�
�y�,�,�
,����8�D�
�y�~�~�
%��b�q��B��a���B��a���B��a���B��F�B���q��B��q��B���A����r�!��A����r�!��A���A����A��&��+�r�1�B�6���A����r�!��A����r�!��A���A����A��&��+�r�1�B�6�	�D�2�C��S�/�!�����������
�
�
�J�N�N�J�,>�,>�
�@R�@R�S�S��N�N�$:��&�&�(B��&�&�(B���	�!#�8�*�,=�>�	?��4�H�:�R�@��
 �'�'�)C�D��(�(�*E�F��'�'�)C�D�����!�9�+�R��q�	�{�!�,��G��
�7�T�Y�Y�w�s��|�4�4�v�=����K�K�C��S�/�!�
�
�
���	�	���:�:��#�!�)�)�H������3����&�$��$�G��%s�
J8c�v�|j�|j|jj|��S)a�
        Transpose image (flip or rotate in 90 degree steps)

        :param method: One of :py:data:`Transpose.FLIP_LEFT_RIGHT`,
          :py:data:`Transpose.FLIP_TOP_BOTTOM`, :py:data:`Transpose.ROTATE_90`,
          :py:data:`Transpose.ROTATE_180`, :py:data:`Transpose.ROTATE_270`,
          :py:data:`Transpose.TRANSPOSE` or :py:data:`Transpose.TRANSVERSE`.
        :returns: Returns a flipped or rotated copy of this image.
        )rr�r$r�)r�r�s  rr�zImage.transpose�
s+��	
�	�	���y�y����*�*�6�2�3�3rc�v�|j�|j|jj|��S)zj
        Randomly spread pixels in an image.

        :param distance: Distance to spread pixels.
        )rr�r$�
effect_spread)r��distances  rr�zImage.effect_spreads+��	
�	�	���y�y����.�.�x�8�9�9rc�b�ddlm}|js
d}t|��|j	|�S)z#Returns a QImage copy of this imager	��ImageQt�Qt bindings are not installed)r�r��qt_is_installedr��toqimage�r�r�r�s   rr�zImage.toqimages/����&�&�1�C��c�"�"�����%�%rc�b�ddlm}|js
d}t|��|j	|�S)z$Returns a QPixmap copy of this imager	r�r�)r�r�r�r��	toqpixmapr�s   rr�zImage.toqpixmaps/����&�&�1�C��c�"�"�� � ��&�&r)NN�r2)r���returnr�r�)rn)rq)r��bool�r��None)r�r�)rFr})NNN)r�rc)^rrr�__doc__r��__annotations__r��!_close_exclusive_fp_after_loadingr��propertyrar`r�r_r�r�r�r�r�rrrrrrr'r,r/r<r?rFrrWrDrrmrOrPr�rIrMr�r��__copy__r�r�r�r�r�r�r�r�rar�r�r�r�rrrrrr�r!r�r*r.r0r8rArCrCr�rRr]rorpr>r?r�rrr�r�r�rrCr�r�r�r�r�r�r�rrrr�r��s���	��F�J��%)��
�)�(,�%�
�����������������
� ���I�6���,
�
�
� �9�(�����0M�	�2 �h
�4"�>)7�V	
���T�7�;�;�s�e�R�����$�$�
L�\	)��H�3�4)�(
�.;�%�62�%)�+�&,�.�.
$�9�>"�H�)�V�7�,�
��
�"&�.
+�
 �#�>!�4O#�b1 �f/3�b7(�r-�$!�F)+�VS�j
�"g>�R6�H�#�#�����u
�n`�D �,!�,�*3�,	�(2�'9�'9��T�x��#�#�
��X�
�X�v2<�1C�1C�!�MH�^4�:�&�'rr�c��eZdZdZy)r7zb
    Used as a mixin by point transforms
    (for use with :py:meth:`~PIL.Image.Image.point`)
    N�rrrr�rrrr7r7%����
	rr7c��eZdZdZy)r�zi
    Used as a mixin by geometry transforms
    (for use with :py:meth:`~PIL.Image.Image.transform`)
    Nr�rrrr�r�.r�rr�c�Z�t�jtjd��S)z+Create grayscale wedge (for debugging only)rn)r�r�r��wedgerrr�_wedger�>s���7�<�<��
�
�3��(�(rc��t|ttf�s
d}t|��t	|�dk7r
d}t|��|ddks|ddkr
d}t|��y)z�
    Common check to enforce type and sanity check on size tuples

    :param size: Should be a 2 tuple of (width, height)
    :returns: True, or raises a ValueError
    zSize must be a tupler*z Size must be a tuple of length 2rr	zWidth and height must be >= 0T)r�r�r�r�rb)r�r�s  r�_check_sizer�Dsb���d�T�5�M�*�$����o��
�4�y�A�~�0����o���A�w��{�d�1�g��k�-����o��rc���t|�|�-t�jtj||��St|t�rddlm}|j||�}t�}|dk(rYt|ttf�rCt|�dvr6ddlm
}|j�|_|jj|�}|jtj|||��S)a�
    Creates a new image with the given mode and size.

    :param mode: The mode to use for the new image. See:
       :ref:`concept-modes`.
    :param size: A 2-tuple, containing (width, height) in pixels.
    :param color: What color to use for the image.  Default is black.
       If given, this should be a single integer or floating point value
       for single-band modes, and a tuple for multi-band modes (one value
       per band).  When creating RGB or HSV images, you can also use color
       strings as supported by the ImageColor module.  If the color is
       None, the image is not initialised.
    :returns: An :py:class:`~PIL.Image.Image` object.
    r	r,rprFr�)r�r�r�r�r�r�r�r�r-r�r�r�rbr�r�r�)r_r��colorr-r$r�s      rr�r�Ys��� ����}��w�|�|�D�H�H�T�4�0�1�1��%���	!��#�#�E�4�0��	��B��s�{�z�%�$���7�C��J�&�<P�"�!�.�.�0��
��
�
�#�#�E�*��
�7�7�4�9�9�T�4��/�0�0rc��t|�t||�}|jdk7rT|jdk7rEt	|�dk(rt|dt�r|d}|dk(r|dk(r|}|j|||�|S)a�
    Creates a copy of an image memory from pixel data in a buffer.

    In its simplest form, this function takes three arguments
    (mode, size, and unpacked pixel data).

    You can also use any pixel decoder supported by PIL. For more
    information on available decoders, see the section
    :ref:`Writing Your Own File Codec <file-codecs>`.

    Note that this function decodes pixel data only, not entire images.
    If you have an entire image in a string, wrap it in a
    :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load
    it.

    :param mode: The image mode. See: :ref:`concept-modes`.
    :param size: The image size.
    :param data: A byte buffer containing raw data for the given mode.
    :param decoder_name: What decoder to use.
    :param args: Additional parameters for the given decoder.
    :returns: An :py:class:`~PIL.Image.Image` object.
    rr	r2r)r�r�rar`rbr�r�rD)r_r�r3r�r�r$s      rrDrD�su��0���	�T�4��B�	�x�x�1�}����a���t�9��>�j��a��%�8���7�D��5� �T�R�Z��D�
���T�<��.�
�Irc	��t|�t|�dk(rt|dt�r|d}|dk(r�|dk(r|ddf}|dtvrxt|d�}|j
tj|||d|��}|dk(r6ddl	m
}|jd|jjd��|_
d|_|St|||||�S)	a�
    Creates an image memory referencing pixel data in a byte buffer.

    This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data
    in the byte buffer, where possible.  This means that changes to the
    original buffer object are reflected in this image).  Not all modes can
    share memory; supported modes include "L", "RGBX", "RGBA", and "CMYK".

    Note that this function decodes pixel data only, not entire images.
    If you have an entire image file in a string, wrap it in a
    :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load it.

    In the current version, the default parameters used for the "raw" decoder
    differs from that used for :py:func:`~PIL.Image.frombytes`.  This is a
    bug, and will probably be fixed in a future release.  The current release
    issues a warning if you do this; to disable the warning, you should provide
    the full set of parameters.  See below for details.

    :param mode: The image mode. See: :ref:`concept-modes`.
    :param size: The image size.
    :param data: A bytes or other buffer object containing raw
        data for the given mode.
    :param decoder_name: What decoder to use.
    :param args: Additional parameters for the given decoder.  For the
        default encoder ("raw"), it's recommended that you provide the
        full set of parameters::

            frombuffer(mode, size, data, "raw", mode, 0, 1)

    :returns: An :py:class:`~PIL.Image.Image` object.

    .. versionadded:: 1.1.4
    r	rr2rr�rpr�rq)r�rbr�r��	_MAPMODESr�r�r��
map_bufferr�r�r$rr�r�rD)r_r�r3r�r�r$r�s       r�
frombufferr��s���F����4�y�A�~�*�T�!�W�e�4��A�w���u���2�:���A�:�D���7�i���T�6�"�B��������t�\�1�d�K�L�B��s�{�*�)�6�6�u�b�e�e�>N�>N�u�>U�V��
��B�K��I��T�4��|�T�:�:rc	�&�|j}|d}t|�}|jdd�}|�	d|ddz|df}	t
|\}}	n|}	|d
vrd}n
|dk(rd}nd
}||kDrd|�d|�d�}t
|��|dk(rdn|d|df}
|�-t|d�r|j�}n|j�}t||
|d|	dd�S#t$r}d}t	|�|�d}~wwxYw#t$r}|\}
}d|
�d	|��}t	|�|�d}~wwxYw)a	
    Creates an image memory from an object exporting the array interface
    (using the buffer protocol)::

      from PIL import Image
      import numpy as np
      a = np.zeros((5, 5))
      im = Image.fromarray(a)

    If ``obj`` is not contiguous, then the ``tobytes`` method is called
    and :py:func:`~PIL.Image.frombuffer` is used.

    In the case of NumPy, be aware that Pillow modes do not always correspond
    to NumPy dtypes. Pillow modes only offer 1-bit pixels, 8-bit pixels,
    32-bit signed integer pixels, and 32-bit floating point pixels.

    Pillow images can also be converted to arrays::

      from PIL import Image
      import numpy as np
      im = Image.open("hopper.jpg")
      a = np.asarray(im)

    When converting Pillow images to arrays however, only pixel values are
    transferred. This means that P and PA mode images will lose their palette.

    :param obj: Object with array interface
    :param mode: Optional mode to use when reading ``obj``. Will be determined from
      type if ``None``.

      This will not be used to convert the data after reading, but will be used to
      change how the data is read::

        from PIL import Image
        import numpy as np
        a = np.full((1, 1), 300)
        im = Image.fromarray(a, mode="L")
        im.getpixel((0, 0))  # 44
        im = Image.fromarray(a, mode="RGB")
        im.getpixel((0, 0))  # (44, 1, 0)

      See: :ref:`concept-modes` for general information about modes.
    :returns: An image object.

    .. versionadded:: 1.1.6
    rf�stridesNr{r*rdzCannot handle this data typezCannot handle this data type: rk)rirnrmrprkrqr+r,zToo many dimensions: z > r�r	rrr2)r<rbr�r�r��_fromarray_typemapr�r%r�tostringr�)�objr_rjrf�ndimr��typekeyr�r�rb�
typekey_shaperd�ndmaxr�s              r�	fromarrayr�sf��^�
!�
!�C���L�E��u�:�D��g�g�i��&�G��|�	(��u�Q�R�y�(�#�i�.�8�G�	(�.�w�7�M�D�'����(�(���	
��������e�|�%�d�V�3�u�g�Q�7����o����	�1�u�Q�x��q��1�D����3�	�"��+�+�-�C��,�,�.�C��d�D�#�u�g�q�!�<�<��9�	(�0�C��C�.�a�'��	(��
�	(�%,�"�M�7�2�=�/��G�9�M�C��C�.�a�'��	(�s/�
C
�C)�
	C&�C!�!C&�)	D�2D�Dc�b�ddlm}|js
d}t|��|j	|�S)z-Creates an image instance from a QImage imager	r�r�)r�r�r�r��
fromqimage�r$r�r�s   rr	r	5s/����"�"�-���#������b�!�!rc�b�ddlm}|js
d}t|��|j	|�S)z.Creates an image instance from a QPixmap imager	r�r�)r�r�r�r��fromqpixmapr
s   rrr?s/����"�"�-���#������r�"�"r)r{z|b1)riz1;8)r{�|u1)rnrn)r{z|i1)rmzI;8)r{z<u2)rmru)r{z>u2)rmrv)r{z<i2)rmzI;16S)r{z>i2)rmzI;16BS)r{z<u4)rmzI;32)r{z>u4)rmzI;32B)r{z<i4)rmzI;32S)r{z>i4)rmzI;32BS)r{z<f4)rkzF;32F)r{z>f4)rkzF;32BF)r{z<f8)rkzF;64F)r{z>f8)rkzF;64BF))r	r	r*r
)rBrB))r	r	r+r
)rqrq))r	r	r,r
)rrrrr{�i4)rmrm�f4)rkrkc��t�ytd|d�td|d�z}|dtzkDrd|�ddtz�d�}t|��|tkDr&tjd|�dt�d�t
�yy)Nr	rr*zImage size (z pixels) exceeds limit of z0 pixels, could be decompression bomb DOS attack.)�MAX_IMAGE_PIXELSrIr r9r:r)r��pixelsr�s   rr�r�ds������
��D��G�_�s�1�d�1�g��
.�F�
��$�$�$��6�(�"<�Q�AQ�=Q�<R�S>�
>�	�%�S�)�)�
� � ��
�
��6�(�"<�=M�<N�O6�
6�$�	
�!rc	��	�
��|dk7rdt|���}t|��t|tj�r
d}t|��|�t
}n#t|ttf�s
d}t|��d�d}t|t�rt|j��}n
t|�r|}|rtj|d�}d�	|jd	�|j'd
�}t)�g�	�	�fd�}|||||�}|�?|t
ur7|j+��
t-�r||||t�
fd�|D���}|r	�|_|S�r|j1��	D]}t3j4|��d
|r|n|z}t7|��#t tj"f$r(tj$|j'��}d�Y��wxYw)a�
    Opens and identifies the given image file.

    This is a lazy operation; this function identifies the file, but
    the file remains open and the actual image data is not read from
    the file until you try to process the data (or call the
    :py:meth:`~PIL.Image.Image.load` method).  See
    :py:func:`~PIL.Image.new`. See :ref:`file-handling`.

    :param fp: A filename (string), pathlib.Path object or a file object.
       The file object must implement ``file.read``,
       ``file.seek``, and ``file.tell`` methods,
       and be opened in binary mode. The file object will also seek to zero
       before reading.
    :param mode: The mode.  If given, this argument must be "r".
    :param formats: A list or tuple of formats to attempt to load the file in.
       This can be used to restrict the set of formats checked.
       Pass ``None`` to try all supported formats. You can print the set of
       available formats by running ``python3 -m PIL`` or using
       the :py:func:`PIL.features.pilinfo` function.
    :returns: An :py:class:`~PIL.Image.Image` object.
    :exception FileNotFoundError: If the file cannot be found.
    :exception PIL.UnidentifiedImageError: If the image cannot be opened and
       identified.
    :exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
       instance is used for ``fp``.
    :exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
    �rz	bad mode zKStringIO cannot be used to open an image. Binary data must be used instead.zformats must be a list or tupleFr��rbTr�c����|D]�}|j�}|tvr
t�	t|\}}|xs||�}t|�tt
fvr�	j
|�n5|r3|jd�|||�}t|j�|cS��y#ttttjf$rY��t$r�
r|j!��wxYwr�)r�r�r��typer�r�rKrr�r��SyntaxError�
IndexErrorr��struct�error�
BaseExceptionr�)r�r�prefix�formatsrw�factory�acceptr5r$�accept_warnings�exclusive_fps         ��r�
_open_corezopen.<locals>._open_core�s�����	�A����	�A���}���
�"&�q�'����#��5�v�f�~����<�C��<�/�#�*�*�6�2���G�G�A�J� ��X�.�B�-�b�g�g�6��I��	�.�� ��Y����E�
�� �
���H�H�J��
�s�A4B$�$#C%�	C%c3�,�K�|]}|�vs�|���
y�wr�r)rvr��checked_formatss  �rryzopen.<locals>.<genexpr>�s�����T��f�O�6S�f�T�s�	�zcannot identify image file %r)�reprr�r�r!�StringIO�IDr�r�r�rr��resolverr�rrr��UnsupportedOperationr"rr�r�r�r�r�r9r:r
)r�r_rr�rrr$r$�messager"r&r#s         @@@rrrys����<�s�{��$�t�*��&����o��	�B����	$�
0�	���o������
��$���
/�/����n���L��H��"�d���r�z�z�|�$��	������
�]�]�8�T�
*�����
����
�
�W�W�R�[�F��I��O��4
�B��&�'�	2�B�	�z�g��m�!�,�,�.���6������T�7�T�T�	�B�
�'����	��
���
�"����
�
�g���
)��X�r�
J�C�
 ��
%�%��s
�B�3�3�4��
�Z�Z����	�
"�����s�F�>G�Gc��|j�|j�|jtj|j|j��S)z�
    Alpha composite im2 over im1.

    :param im1: The first image. Must have mode RGBA.
    :param im2: The second image.  Must have mode RGBA, and the same size as
       the first image.
    :returns: An :py:class:`~PIL.Image.Image` object.
    )rr�r�r0r$)�im1�im2s  rr0r0�s:���H�H�J��H�H�J��8�8�D�(�(�������8�9�9rc��|j�|j�|jtj|j|j|��S)a�
    Creates a new image by interpolating between two input images, using
    a constant alpha::

        out = image1 * (1.0 - alpha) + image2 * alpha

    :param im1: The first image.
    :param im2: The second image.  Must have the same mode and size as
       the first image.
    :param alpha: The interpolation alpha factor.  If alpha is 0.0, a
       copy of the first image is returned. If alpha is 1.0, a copy of
       the second image is returned. There are no restrictions on the
       alpha value. If necessary, the result is clipped to fit into
       the allowed output range.
    :returns: An :py:class:`~PIL.Image.Image` object.
    )rr�r��blendr$)r.r/rs   rr1r1
s:��$�H�H�J��H�H�J��8�8�D�J�J�s�v�v�s�v�v�u�5�6�6rc�L�|j�}|j|d|�|S)af
    Create composite image by blending images using a transparency mask.

    :param image1: The first image.
    :param image2: The second image.  Must have the same mode and
       size as the first image.
    :param mask: A mask image.  This image can have mode
       "1", "L", or "RGBA", and must have the same size as the
       other two images.
    N)r�r.)�image1�image2r'r�s    r�	compositer5
s$��
�K�K�M�E�	�K�K���d�#��Lrc�*�|j|d�S)a�
    Applies the function (which should take one argument) to each pixel
    in the given image. If the image has more than one band, the same
    function is applied to each band. Note that the function is
    evaluated once for each possible pixel value, so you cannot use
    random components or other generators.

    :param image: The input image.
    :param function: A function object, taking one integer argument.
    :returns: An :py:class:`~PIL.Image.Image` object.
    r)r8)r�r�s  r�evalr7+
s���;�;�t�A�w��rc	��t|�t|�k7sd|vr
d}t|��|ddD]P}|jt	|�k7r
d}t|��|j
|dj
k7s�Ed}t|��|D]}|j
��|djtj|g|D�cgc]}|j��c}����Scc}w)am
    Merge a set of single band images into a new multiband image.

    :param mode: The mode to use for the output image. See:
        :ref:`concept-modes`.
    :param bands: A sequence containing one single-band image for
        each band in the output image.  All bands must have the
        same size.
    :returns: An :py:class:`~PIL.Image.Image` object.
    �*zwrong number of bandsr	Nz
mode mismatchrz
size mismatch)r�rbr�r_r}r�rr�r�r�r$)r_rcr�r�r&s     rr�r�;
s����D��S��Z�'�3�$�;�%����o���a�b�	�"���9�9��D�)�)�!�C��S�/�!��9�9��a��
�
�%�!�C��S�/�!�
"�����	�	�����8�=�=����D�A�%�+@�Q�A�D�D�+@�A�B�B��+@s�;Cc�t�|j�}|tvrtj|�||ft|<y)a1
    Register an image file plugin.  This function should not be used
    in application code.

    :param id: An image format identifier.
    :param factory: An image file factory method.
    :param accept: An optional function that can be used to quickly
       reject images having another format.
    N)r�r)rKr�)rr r!s   r�
register_openr;Z
s.��
����B�	��|�
�	�	�"�
����D��Hrc�2�|t|j�<y)a�
    Registers an image MIME type by populating ``Image.MIME``. This function
    should not be used in application code.

    ``Image.MIME`` provides a mapping from image format identifiers to mime
    formats, but :py:meth:`~PIL.ImageFile.ImageFile.get_format_mimetype` can
    provide a different result for specific images.

    :param id: An image format identifier.
    :param mimetype: The image MIME type for this format.
    N)�MIMEr�)r�mimetypes  r�
register_mimer?j
s�� �D�����rc�2�|t|j�<y)z�
    Registers an image save function.  This function should not be
    used in application code.

    :param id: An image format identifier.
    :param driver: A function to save images in this format.
    N)r�r��r�drivers  r�
register_saverCy
s���D�����rc�2�|t|j�<y)z�
    Registers an image function to save all the frames
    of a multiframe format.  This function should not be
    used in application code.

    :param id: An image format identifier.
    :param driver: A function to save images in this format.
    N)r�r�rAs  r�register_save_allrE�
s��"�H�R�X�X�Z�rc�N�|j�t|j�<y)z�
    Registers an image extension.  This function should not be
    used in application code.

    :param id: An image format identifier.
    :param extension: An extension used for this format.
    N)r�r�r�)r�	extensions  r�register_extensionrH�
s��$&�8�8�:�I�i�o�o�� rc�*�|D]}t||��y)z�
    Registers image extensions.  This function should not be
    used in application code.

    :param id: An image format identifier.
    :param extensions: A list of extensions used for this format.
    N)rH)r�
extensionsrGs   r�register_extensionsrK�
s�� �*�	��2�y�)�*rc�"�t�tS)za
    Returns a dictionary containing all file extensions belonging
    to registered plugins
    )r�r�rrr�registered_extensionsrM�
s��
	�F��rc��|t|<y)a
    Registers an image decoder.  This function should not be
    used in application code.

    :param name: The name of the decoder
    :param decoder: A callable(mode, args) that returns an
                    ImageFile.PyDecoder object

    .. versionadded:: 4.1.0
    N)r�)rVr�s  r�register_decoderrO�
�
���H�T�Nrc��|t|<y)a
    Registers an image encoder.  This function should not be
    used in application code.

    :param name: The name of the encoder
    :param encoder: A callable(mode, args) that returns an
                    ImageFile.PyEncoder object

    .. versionadded:: 4.1.0
    N)r�)rVr�s  r�register_encoderrR�
rPrc�6�ddlm}|j|fi|��y)Nr	)�	ImageShow)r�rTr�)r�rrTs   rr�r��
s����I�N�N�5�$�G�$rc�^�t�jtj|||��S)a
    Generate a Mandelbrot set covering the given extent.

    :param size: The requested size in pixels, as a 2-tuple:
       (width, height).
    :param extent: The extent to cover, as a 4-tuple:
       (x0, y0, x1, y1).
    :param quality: Quality.
    )r�r�r��effect_mandelbrot)r��extent�qualitys   rrVrV�
s$���7�<�<��.�.�t�V�W�E�F�Frc�\�t�jtj||��S)z�
    Generate Gaussian noise centered around 128.

    :param size: The requested size in pixels, as a 2-tuple:
       (width, height).
    :param sigma: Standard deviation of noise.
    )r�r�r��effect_noise)r��sigmas  rrZrZ�
s"���7�<�<��)�)�$��6�7�7rc�Z�t�jtj|��S)zl
    Generate 256x256 linear gradient from black to white, top to bottom.

    :param mode: Input mode.
    )r�r�r��linear_gradientrys rr]r]�
� ���7�<�<��,�,�T�2�3�3rc�Z�t�jtj|��S)zm
    Generate 256x256 radial gradient from black to white, centre to edge.

    :param mode: Input mode.
    )r�r�r��radial_gradientrys rr`r`�
r^rc��|�tj}dtjfdtjfdtj
ffD]d\}}||vr�||j
�}d}dD](\}}|j|�s�|}|dt|�}�*	t|�|z}	||��fy#t$rtj|�d��Y��wxYw#t$r$}tj|�d|���Yd}~��d}~wwxYw)N�PILLOW_ALIGNMENT�PILLOW_BLOCK_SIZE�PILLOW_BLOCKS_MAXr	))r�i)reiz is not intz: )
r	�environr��
set_alignment�set_block_size�set_blocks_maxr�r
rbrcr�r9r:)�env�var_name�setter�var�units�postfix�mulr�s        r�_apply_env_variablesrps��
�{��j�j��
�T�/�/�0�	�d�1�1�2�	�d�1�1�2��.���&�
�3����(�m�!�!�#����=�	+�L�G�S��|�|�G�$����/�S��\�M�*��	+�
	��c�(�U�"�C�
	.��3�K�/.��$�	��M�M�X�J�k�2�3��	���	.��M�M�X�J�b���,�-�-��	.�s*�B0�%C�0!C�C�	D� C?�?Dc��eZdZdZdZdZd�Zd�Zd�Zd�Z	d�Z
d	�Zdd
�Zd�Z
dd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)r�a
    This class provides read and write access to EXIF image data::

      from PIL import Image
      im = Image.open("exif.png")
      exif = im.getexif()  # Returns an instance of this class

    Information can be read and written, iterated over or deleted::

      print(exif[274])  # 1
      exif[274] = 2
      for k, v in exif.items():
        print("Tag", k, "Value", v)  # Tag 274 Value 2
      del exif[274]

    To access information beyond IFD0, :py:meth:`~PIL.Image.Exif.get_ifd`
    returns a dictionary::

      from PIL import ExifTags
      im = Image.open("exif_gps.jpg")
      exif = im.getexif()
      gps_ifd = exif.get_ifd(ExifTags.IFD.GPSInfo)
      print(gps_ifd)

    Other IFDs include ``ExifTags.IFD.Exif``, ``ExifTags.IFD.Makernote``,
    ``ExifTags.IFD.Interop`` and ``ExifTags.IFD.IFD1``.

    :py:mod:`~PIL.ExifTags` also has enum classes to provide names for data::

      print(exif[ExifTags.Base.Software])  # PIL
      print(gps_ifd[ExifTags.GPS.GPSDateStamp])  # 1999:99:99 99:99:99
    NFc�J�i|_i|_i|_d|_d|_yr�)�_data�_hidden_data�_ifdsr��_loaded_exifr�s rr�z
Exif.__init__Qs'����
������
���
� ��rc�n�	t|�dk(rt|t�r|dS|S#t$rY|SwxYwr�)rbr�r�r�)r�r�s  r�_fixupzExif._fixupXsD��	��5�z�Q��:�e�U�#;��Q�x������	����	�s�"'�	4�4c�t�|j�D��cic]\}}||j|���c}}Scc}}wr�)r�rx)r��src_dictr�rss    r�_fixup_dictzExif._fixup_dict`s0��/7�n�n�.>�?�d�a���4�;�;�q�>�!�?�?��?s�4c��	|jj|�ddlm}|j	|j
�}|j
|j�|j|�S#ttf$rYywxYw)Nr	��TiffImagePlugin)
r�rr�r~�ImageFileDirectory_v2�headrr{r�r�)r�r�r~r�s    rr�zExif._get_ifd_dictesl��	*�
�G�G�L�L�� �
*�"�8�8����C�D��I�I�d�g�g���#�#�D�)�)���)�$�	��	�s�A*�*A<�;A<c��|jrdnd}|jdk(rd|zdztd�z}nd|ztd�z}|jr-||jdk(rtd�n
td�z
}|dz
}|S)	N�+�*rZsII�r�sMMs)r�r�rr)r�r1r�s   r�	_get_headzExif._get_headss{��!�\�\�'�w���;�;�#���7�?�W�,�u�Q�x�7�D��w�&��q��1�D��<�<�����s� 2�E�!�H��a��@�D��'�'�D��rc��||jk(ry||_|jj�|jj�|jj�|r|jd�r|dd}|sd|_ytj|�|_	|jjd�|_ddlm
}|j|j�|_|jj|_|jj#|jj$�|jj'|j�y)N�Exifr.r�r	r})rvrs�clearrtrurfr�r!r"r�rr�r�r~rr�r�rr�r)r�r3r~s   rrz	Exif.load~s����4�$�$�$�� ����
�
���������!��
�
�����D�O�O�O�4����8�D���D�J���*�*�T�"����G�G�L�L��O��	�%�$�:�:�4�9�9�E��
��j�j�(�(��������T�Z�Z�_�_�%��
�
������ rc��d|_|jj�|jj�|jj�ddlm}||_|�|j�|_	n |jjd�|_	|j|j�|_|j�|jj|_
|�|jj}|jj!�|jj#|�|jj%|j�y)Nr	r}r�)rvrsr�rtrur�r~r�r�r�rrr�r�r�r�rrr)r�r�r�r~s    rr�zExif.load_from_fp�s��� ����
�
���������!��
�
����	&���������(�D�I������Q��D�I�$�:�:�4�9�9�E��
��;�;���*�*�,�,�D�K��>��Z�Z�_�_�F������������V���
�
������ rc��t|�}tjj|vr?|j	|tjj�}|r|j|�tjj|vrG|j	|tjj�|tjj<|Sr�)�dictr
r�r�r��update�GPSInfo)r��merged_dictrs   r�_get_merged_dictzExif._get_merged_dict�s����4�j���<�<����$��$�$�T�(�,�,�*;�*;�%<�=�C���"�"�3�'��<�<���4�'�04�0B�0B��X�\�\�)�)�*�1�K����,�,�-��rc���ddlm}|j�}|j|��}|j	�D�]\}}|t
jjt
jjfvr�t|t�s�|j|�}|t
jjk(r�t
jj|vrt|t
jjt�sT|j�}|jt
jj�|t
jj<|||<��d|z|j|�zS)Nr	r})�ifhr�)r�r~r�rr�r
r�r�r�r�r�r��Interopr�r)r�r�r~r�rr�r�s       rrzExif.tobytes�s��%��~�~����3�3��3�=���*�*�,�
	�J�C������!�!����$�$���!���-����S�)���8�<�<�,�,�,� ���,�,��5�&�u�X�\�\�-A�-A�'B�D�I�!�J�J�L�E�26�,�,�x�|�|�?S�?S�2T�E�(�,�,�.�.�/��C��H�
	���%����F�(;�;�;rc	���||jv�r.|tjjk(r[|j��|jj
dk7�r�|j
|jj
�|j|<�n�|tjjtjjfvrN|jj||j|��}|��R|j
|�|j|<�n2|tjjtjjfv�r�tjj|jvr)|jtjj�|jtjj|}|tjjk(�rFddlm}|dddk(�r(t!|d�}||d}i}t#dt%j&d|dd�d�D]�}t%j&d||d	zdz|dzd	zdz�\}	}
}}	|j(|
\}
}||
z}|d
kDr't%j&d|�\}||d	z
||zd	z
}n|d|}t-|�|k7r(t/j0d|�d
t-|��d|	�����|s��||�|d�||	<��t3|j5|��|j|<�n-|jd�dk(�ri}t#dt%j&d|dd�d�D�]�}t%j&d||d	zdz|dzd	zdz�\}	}
}}|	dk(s�7t%j&d|�\}|j6j9|�d|j6j;d
�i}|j6j;d
�t!|j6j;d	��|d<|j6j;d
�|j6j;d
�|d<|j6j;d	�|j6j;d
�}|j(t<j>d}||�|d�|d<|j6j;d
�|j6j;d�|d<dt3|j5|��i}���||j|<n|j
|�|j|<|jj|i�}|tjjk(re|jrY|jA�D��cic]>\}}|tjjtjjfvr||��@}}}|S#t*$rY���wxYwcc}}w)Nrr	)rr�sFUJIFILMz<Hr*z<HHL4s�r,z<Lz9Possibly corrupt EXIF MakerNote data.  Expecting to read z bytes but only got z. Skipping tag Fi�Nintendoz>Hz>HHL4siz>L�ModelID�	TimeStamp�InternalSerialNumber�Parallax�Category)!rur
r�r�r�r�r�r�r�rtr�r��	Makernoter�r~rrr�r�unpack�_load_dispatchr�rbr9r:r�r{r�rrr�FLOATr�)r�r�r��tag_datarr
�ifd_data�	makernoterw�ifd_tag�typ�countr3�	unit_size�handlerr��
camerainfo�parallaxrr�rss                     rr�zExif.get_ifd�s ���d�j�j� ��h�l�l�'�'�'��:�:�)�d�j�j�o�o��.B�&*�&8�&8������&I�D�J�J�s�O�����*�*�H�L�L�,@�,@�A�A��*�*�.�.�s�D�H�H�S�M�B���%�&*�&8�&8��&@�D�J�J�s�O�����-�-�x�|�|�/E�/E�F�F��<�<�$�$�D�J�J�6��L�L����!2�!2�3��:�:�h�l�l�&7�&7�8��=���(�,�,�0�0�0�F����|�{�2�%*�8�Q�%7�
�#+�J�K�#8��$&�	�!&�q�&�-�-��h�r��l�*K�A�*N�!O��A�8>�
�
� (�(�1�r�6�A�:��Q��"��q�@P�*Q�9�5�G�S�%��)�%:�$H�$H��$M�!"�$-�$+�$)�9�#4�D�#�a�x�,2�M�M�$��,E�	��'/����f�t�m�b�>P�'Q��'+�E�T�{��"�4�y�D�0� (�
�
�%9�9=��>R�'*�4�y�k���	�%K�!"�
!)�#'� (�18� 5� 7��u�2�I�g�.�;�@+/�t�/?�/?�	�/J�*K��
�
�3�����&�)�Z�7�$&�	�!&�q�&�-�-��h�r��l�*K�A�*N�!O�Y�A�8>�
�
� (�(�1�r�6�A�:��Q��"��q�@P�*Q�9�5�G�S�%�� '�&�0�,2�M�M�$��,E�	�� $�����V� 4�.7������a��-I�
� $�����Q��:?������R�@P�:Q�
�;� 7� $�����Q��EI�W�W�\�\�RS�_�
�+A� B� $�����R� 0�+/�7�7�<�<��?��*?�*N�*N�$,�N�N�+"�"#�+%��:A�$9�$;�X�u�:"�
�:� 6�!%�����Q��9=�����a��
�:� 6�-3�T�$�:J�:J�:�:V�5W�,X�	�=Y�>+4��
�
�3��'+�&8�&8��&B�D�J�J�s�O��j�j�n�n�S�"�%���(�,�,�#�#�#��(9�(9�"�i�i�k���Q���X�\�\�1�1�8�<�<�3I�3I�J�J��1���C��
�
��I$,�)� (�)��~s�W�AW.�	W+�*W+c��tjjtjjfD]}||vs�|||j|<||=�yr�)r
r�r�r�rt�r�r�s  r�hide_offsetszExif.hide_offsets<sL���L�L�%�%�x�|�|�';�';�<�	�C��d�{�)-�c���!�!�#�&���I�	rc�p�|j�|jD]}||�	t|j�Sr�)r�r�rsr�s  r�__str__zExif.__str__Bs6���:�:�!��z�z�
���S�	�
��4�:�:��rc��t|j�}|j�|j|j�t	|�Sr�)�setrsr�r�rb�r��keyss  r�__len__zExif.__len__Js3���4�:�:����:�:�!��K�K��
�
�#��4�y�rc���|j�T||jvrF||jvr8|j|j|�|j|<|j|=|j|Sr�)r�rsrxr�s  r�__getitem__zExif.__getitem__PsY���:�:�!�c����&;��t�z�z�@Q�"�k�k�$�*�*�S�/�:�D�J�J�s�O��
�
�3���z�z�#��rc�^�||jvxs|jduxr||jvSr�)rsr�r�s  r�__contains__zExif.__contains__Vs-���d�j�j� �R�T�Z�Z�t�%;�%Q��t�z�z�@Q�Rrc�p�|j�||jvr
|j|=||j|<yr��r�rs)r�r�r�s   r�__setitem__zExif.__setitem__Ys/���:�:�!�c�T�Z�Z�&7��
�
�3����
�
�3�rc�n�|j�||jvr|j|=y|j|=yr�r�r�s  r�__delitem__zExif.__delitem__^s-���:�:�!�c�T�Z�Z�&7��
�
�3���
�
�3�rc��t|j�}|j�|j|j�t	|�Sr�)r�rsr�r��iterr�s  r�__iter__z
Exif.__iter__ds3���4�:�:����:�:�!��K�K��
�
�#��D�z�rr�)r�)rrrr�r�r�r�rxr{r�r�rr�r�rr�r�r�r�r�r�r�r�r�rrrr�r�,sr���B�F��G�!��@�
*�	�!�:!�.�"<�*b�H����S� �
 �rr�)r)rr�r�r�)rNr�)��
__future__r�atexitr�r!�loggingrUr	r�rr�rr9�collections.abcrr�enumr�pathlibr�
defusedxmlrr�r�r
rrr
rr�_binaryrrr�_utilrr�	getLoggerrr��RuntimeWarningrr�r rcrr!r�r�r�rsr�r�rfr:rhrgr'r)r7r>r@rArBrCrDrTrIrOrS�modules�module�item�setattrrVr�r%rX�FILTERED�HUFFMAN_ONLY�RLE�FIXEDr)r�r=r�r�r�r�r��	byteorder�_ENDIANrh�MODESr�rzr}rr�r�r�r�r�r�r�r�r�r7r�r�r�rDr�rr	rrr�rr0r1r5r7r�r;r?rCrErHrKrMrOrRr�rVrZr]r`rp�register�clear_cacher�rrr�<module>r�s:��6#�
��	���	�	�
�
���4����&���)�(�)�	��	�	�8�	$��	�~�	�	�Y�	�
�3�4��
�#��g�d�$4�d�;�;�
�$�T�+;�T�B�C�D�*�m�
-�	�
�#���
<�4����
�&���
��
�����N�N�C��������������������W���g��
�w��

���X�	��
�	�:�v�w��I�/�D��/�����	�	�4�:�:�.�/�/�
�4�#�$��,�,���}�}�H��$�$�L�
�(�(�C��J�J�E���	��	��	��
���	�
��
��
���(�*�#����	X��
I�	�
,�	,�)�.���*�Z�<(�.(�6;�;�D@�H%'�H%'�^J	�	�	�	� )��*$1�N$�N6;�rR=�j"�#���\���Z�	�
�\���]�
��^���^���_���]���^���^���_���^���_�� �^�!�"�_�#�$��%�&��'�(�(��W�t�^��j��W�t�^��j�/��6
�*t&�v:�7�.�"
 � C�>
�  ��	"�.�	*����$%�
G�8�4�4�.�@������� � �!�|�>�|��}o���K���`�
��=���[�)R�S�T�D�
�1�v���/�0�	��
�
�M��	
�
�	

�Q��	�	�3�	4���
�
�c�!�f�n�-�
��
��*���D��s=�L.�!+L<�N=�.L9�8L9�<N:�A4N5�5N:�=O�O

Zerion Mini Shell 1.0