Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/PIL/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/PIL/__pycache__/ImageMath.cpython-312.pyc

�

&ٜg�.���ddlmZddlZddlmZddlmZmZddlm	Z	m
Z
ddlmZGd�d	�Z
dd
�Zdd�Zdd�Zdd
�Zdd�Zdd�Zdd�Zeeeeeeed�Zif							dd�Zif							dd�Zif							dd�Zy)�)�annotationsN)�CodeType)�Any�Callable�)�Image�_imagingmath)�	deprecatec�8�eZdZdZd%d�Zd&d�Z		d'									d(d�Zd)d�Zd*d�Zd*d�Z	d*d	�Z
d+d
�Zd+d�Zd+d�Z
d+d
�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd*d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Z d+d �Z!d+d!�Z"d+d"�Z#d+d#�Z$d+d$�Z%y),�_Operandz4Wraps an image operand, providing standard operatorsc��||_y�N)�im)�selfrs  �8/usr/local/lib/python3.12/site-packages/PIL/ImageMath.py�__init__z_Operand.__init__s	�����c� �t|t�r{|jjdvr|jj	d�S|jjdvr|jSd|jj��}t|��t|ttf�rC|jjdvr+tjd|jj|�Stjd|jj|�S)N)�1�L�I)r�Fzunsupported mode: )rrrr)�
isinstancerr�mode�convert�
ValueError�int�floatr�new�size)r�im1�msgs   r�__fixupz_Operand.__fixup!s����c�8�$��v�v�{�{�j�(��v�v�~�~�c�*�*������
�*��v�v�
�*�3�6�6�;�;�-�8�� ��o�%��#��U�|�,�������1P��y�y��d�g�g�l�l�C�8�8��y�y��d�g�g�l�l�C�8�8rNc�0�|j|�}|��tj|xs|j|jd�}	tt|�d|j���}t
j||j�|j��t|�S|j|�}	|j|	jk7r@|jdk7r|jd�}|	jdk7r|	jd�}	|j|	jk7r�t|jd|	jd�t|jd|	jd�f}
|j|
k7r|jd|
z�}|	j|
k7r|	jd|
z�}	tj|xs|j|jd�}	tt|�d|j���}t
j||j�|j�|	j��t|�S#t$r}d|�d�}t|�|�d}~wwxYw#t$r}d|�d�}t|�|�d}~wwxYw)N�_zbad operand type for '�'rrr)rr)�_Operand__fixuprrrr �getattrr	�AttributeError�	TypeError�unop�getimr�min�crop�binopr)r�opr!�im2r�im_1�out�er"�im_2r s           r�applyz_Operand.apply3s)���|�|�C� ���;��)�)�D�-�D�I�I�t�y�y�$�?�C�
,��\�b�T��4�9�9�+�+>�?��
���b�#�)�)�+�t�z�z�|�<�6��}��1�<�<��$�D��y�y�D�I�I�%��9�9��#��<�<��,�D��9�9��#��<�<��,�D��y�y�D�I�I�%���	�	�!��d�i�i��l�3���	�	�!��d�i�i��l�3����9�9��$��9�9�V�d�]�3�D��9�9��$��9�9�V�d�]�3�D��)�)�D�-�D�I�I�t�y�y�$�?�C�
,��\�b�T��4�9�9�+�+>�?��
���r�3�9�9�;��
�
��d�j�j�l�K���}���="�
,�.�r�d�!�4����n�!�+��
,��4"�
,�.�r�d�!�4����n�!�+��
,�s0�I�&I5�	I2�I-�-I2�5	J�>J�Jc�:�|jj�duSr)r�getbbox�rs r�__bool__z_Operand.__bool__as���w�w��� ��,�,rc�&�|jd|�S)N�abs�r6r9s r�__abs__z_Operand.__abs__e����z�z�%��&�&rc��|Sr�r9s r�__pos__z_Operand.__pos__hs���rc�&�|jd|�S)N�negr=r9s r�__neg__z_Operand.__neg__kr?rc�(�|jd||�S�N�addr=�r�others  r�__add__z_Operand.__add__o����z�z�%��u�-�-rc�(�|jd||�SrGr=rIs  r�__radd__z_Operand.__radd__r����z�z�%���-�-rc�(�|jd||�S�N�subr=rIs  r�__sub__z_Operand.__sub__urLrc�(�|jd||�SrQr=rIs  r�__rsub__z_Operand.__rsub__xrOrc�(�|jd||�S�N�mulr=rIs  r�__mul__z_Operand.__mul__{rLrc�(�|jd||�SrWr=rIs  r�__rmul__z_Operand.__rmul__~rOrc�(�|jd||�S�N�divr=rIs  r�__truediv__z_Operand.__truediv__�rLrc�(�|jd||�Sr]r=rIs  r�__rtruediv__z_Operand.__rtruediv__�rOrc�(�|jd||�S�N�modr=rIs  r�__mod__z_Operand.__mod__�rLrc�(�|jd||�Srcr=rIs  r�__rmod__z_Operand.__rmod__�rOrc�(�|jd||�S�N�powr=rIs  r�__pow__z_Operand.__pow__�rLrc�(�|jd||�Srir=rIs  r�__rpow__z_Operand.__rpow__�rOrc�&�|jd|�S)N�invertr=r9s r�
__invert__z_Operand.__invert__�s���z�z�(�D�)�)rc�(�|jd||�S�N�andr=rIs  r�__and__z_Operand.__and__�rLrc�(�|jd||�Srrr=rIs  r�__rand__z_Operand.__rand__�rOrc�(�|jd||�S�N�orr=rIs  r�__or__z_Operand.__or__�����z�z�$��e�,�,rc�(�|jd||�Srxr=rIs  r�__ror__z_Operand.__ror__�s���z�z�$��t�,�,rc�(�|jd||�S�N�xorr=rIs  r�__xor__z_Operand.__xor__�rLrc�(�|jd||�Srr=rIs  r�__rxor__z_Operand.__rxor__�rOrc�(�|jd||�S)N�lshiftr=rIs  r�
__lshift__z_Operand.__lshift__�����z�z�(�D�%�0�0rc�(�|jd||�S)N�rshiftr=rIs  r�
__rshift__z_Operand.__rshift__�r�rc�(�|jd||�S)N�eqr=rIs  r�__eq__z_Operand.__eq__�r{rc�(�|jd||�S)N�ner=rIs  r�__ne__z_Operand.__ne__�r{rc�(�|jd||�S)N�ltr=rIs  r�__lt__z_Operand.__lt__�r{rc�(�|jd||�S)N�ler=rIs  r�__le__z_Operand.__le__�r{rc�(�|jd||�S)N�gtr=rIs  r�__gt__z_Operand.__gt__�r{rc�(�|jd||�S)N�ger=rIs  r�__ge__z_Operand.__ge__�r{r)r�Image.Image)r!�_Operand | float�returnr�)NN)
r0�strr!r�r1�_Operand | float | Nonerz
str | Noner�r)r��bool)r�r)rJr�r�r)&�__name__�
__module__�__qualname__�__doc__rr'r6r:r>rBrErKrNrSrUrYr[r_rarergrkrmrprtrvrzr}r�r�r�r�r�r�r�r�r�r�rArrrrs���>��9�,(,��+��+��+�%�	+�
�+�
�
+�\-�'��'�.�.�.�.�.�.�.�.�.�.�.�.�*�.�.�-�-�.�.�1�1�-�-�-�-�-�-rrc�J�t|jjd��S)Nr�rrrr9s r�
imagemath_intr������D�G�G�O�O�C�(�)�)rc�J�t|jjd��S)Nrr�r9s r�imagemath_floatr��r�rc�,�|jd||d��S)Nr�r�rr=rIs  r�imagemath_equalr������:�:�d�D�%�c�:�2�2rc�,�|jd||d��S)Nr�rr�r=rIs  r�imagemath_notequalr��r�rc�(�|jd||�S)Nr-r=rIs  r�
imagemath_minr������:�:�e�T�5�)�)rc�(�|jd||�S)N�maxr=rIs  r�
imagemath_maxr��r�rc�J�t|jj|��Srr�)rrs  r�imagemath_convertr��s���D�G�G�O�O�D�)�*�*r)rr�equal�notequalr-r�rc�Z�|r
tddd�tj�}|j|�|j|�|j	�D].\}}t|tj�s�!t|�||<�0||�}	|jS#t$r|cYSwxYw)a�
    Returns the result of an image function.

    :py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band
    images, use the :py:meth:`~PIL.Image.Image.split` method or
    :py:func:`~PIL.Image.merge` function.

    :param expression: A function that receives a dictionary.
    :param options: Values to add to the function's dictionary. Deprecated.
                    You can instead use one or more keyword arguments.
    :param **kw: Values to add to the function's dictionary.
    :return: The expression result. This is usually an image object, but can
             also be an integer, a floating point value, or a pixel tuple,
             depending on the expression.
    zImageMath.lambda_eval options�z'ImageMath.lambda_eval keyword arguments)
r
�ops�copy�update�itemsrrrrr))�
expression�options�kw�args�k�vr3s       r�lambda_evalr��s���*��+��5�	
��8�8�:�D��K�K����K�K��O��
�
����1��a����%��q�k�D��G���T�
�C���v�v�
�����
��s�B�B*�)B*c����	�|r
tddd�tj��t|j	��t|j	��zD]'}d|vstt|�s�d|�d�}t|���j|��j|��j�D].\}}t|tj�s�!t|��|<�0t|dd��d���	fd	��	�	��t
j|d
dtii��}	|j S#t"$r|cYSwxYw)
a�
    Evaluates an image expression. This uses Python's ``eval()`` function to process
    the expression string, and carries the security risks of doing so. It is not
    recommended to process expressions without considering this.
    :py:meth:`~lambda_eval` is a more secure alternative.

    :py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band
    images, use the :py:meth:`~PIL.Image.Image.split` method or
    :py:func:`~PIL.Image.merge` function.

    :param expression: A string containing a Python-style expression.
    :param options: Values to add to the evaluation context. Deprecated.
                    You can instead use one or more keyword arguments.
    :param **kw: Values to add to the evaluation context.
    :return: The evaluated expression. This is usually an image object, but can
             also be an integer, a floating point value, or a pixel tuple,
             depending on the expression.
    zImageMath.unsafe_eval optionsr�z'ImageMath.unsafe_eval keyword arguments�__r&�
' not allowedz<string>�evalc���|jD]!}t|�t��us��|��#|jD]}|�vs�|dk7s�d|�d�}t|��y)Nr<r&r�)�	co_consts�type�co_namesr)�code�const�namer"r��
compiled_code�scans    ���rr�zunsafe_eval.<locals>.scanDs_����^�^�E��E�{�d�=�1�1��U��$��M�M�D��4��D�E�M��$��}�-�� ��o�%�"r�
__builtinsr<)r�rr��None)r
r�r��list�keys�hasattr�builtinsrr�r�rrr�compiler�r<rr))
r�r�r�r�r"r�r3r�r�r�s
       @@@r�unsafe_evalr�s���0��+��5�	
��8�8�:�D�
�'�,�,�.�
!�D�����O�
3���1�9���!�,��a�S�
�&�C��S�/�!�4�
	�K�K����K�K��O��
�
����1��a����%��q�k�D��G���J�
�F�;�M�&�	���
�-�-�
�\�E�3�<�$@�$�
G�C���v�v�
�����
��s�$D0�0D>�=D>c�6�tddd�t||fi|��S)a1
    Evaluates an image expression.

    Deprecated. Use lambda_eval() or unsafe_eval() instead.

    :param expression: A string containing a Python-style expression.
    :param _dict: Values to add to the evaluation context.  You
                  can either use a dictionary, or one or more keyword
                  arguments.
    :return: The evaluated expression. This is usually an image object, but can
             also be an integer, a floating point value, or a pixel tuple,
             depending on the expression.

    ..  deprecated:: 10.3.0
    zImageMath.evalr�z.ImageMath.lambda_eval or ImageMath.unsafe_eval)r
r�)r��_dictr�s   rr�r�Vs)��*��
�8��
�z�5�/�B�/�/r)rrr�r)rrrJr�r�r)rrrr�r�r)r�zCallable[[dict[str, Any]], Any]r��dict[str, Any]r�rr�r)r�r�r�r�r�rr�r)r�r�r�r�r�rr�r)�
__future__rr��typesr�typingrr�rr	�
_deprecater
rr�r�r�r�r�r�r�r�r�r�r�rArr�<module>r�s���"#��� �!�!�e-�e-�R*�*�
3�3�*�*�+�
�
�
�"��� ���!�'�/�'�
�'��'�	�	'�X!�=��=�
�=��=�	�	=�D�0��0��0��0�	�	0r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists