§
    aÒ³g¦.  ã                  óÜ   — d dl mZ d dlZd dlmZ d dlmZmZ ddlm	Z	m
Z
 ddlmZ  G d„ d	¦  «        Zd"d„Zd"d„Zd#d„Zd#d„Zd#d„Zd#d„Zd$d„ZeeeeeeedœZi fd%d„Zi fd&d„Zi fd'd!„ZdS )(é    )ÚannotationsN)ÚCodeType)ÚAnyÚCallableé   )ÚImageÚ_imagingmath)Ú	deprecatec                  ó(  — e Zd ZdZd2d„Zd3d„Z	 	 d4d5d„Zd6d„Zd7d„Zd7d„Z	d7d„Z
d8d„Zd8d„Zd8d„Zd8d„Zd8d„Zd8d„Zd8d„Zd8d„Zd8d„Zd8d „Zd8d!„Zd8d"„Zd7d#„Zd8d$„Zd8d%„Zd8d&„Zd8d'„Zd8d(„Zd8d)„Zd8d*„Zd8d+„Zd8d,„Z d8d-„Z!d8d.„Z"d8d/„Z#d8d0„Z$d8d1„Z%d	S )9Ú_Operandz4Wraps an image operand, providing standard operatorsÚimúImage.Imagec                ó   — || _         d S ©N)r   )Úselfr   s     úK/var/www/html/mpstechhub/venv/lib/python3.11/site-packages/PIL/ImageMath.pyÚ__init__z_Operand.__init__   s   € ØˆŒˆˆó    Úim1ú_Operand | floatÚreturnc                ó¶  — t          |t          ¦  «        r[|j        j        dv r|j                             d¦  «        S |j        j        dv r|j        S d|j        j        › �}t          |¦  «        ‚t          |t          t          f¦  «        r.| j        j        dv r t          j	        d| j        j
        |¦  «        S t          j	        d| j        j
        |¦  «        S )N)Ú1ÚLÚI)r   ÚFzunsupported mode: )r   r   r   r   )Ú
isinstancer   r   ÚmodeÚconvertÚ
ValueErrorÚintÚfloatr   ÚnewÚsize)r   r   Úmsgs      r   Ú__fixupz_Operand.__fixup!   sÀ   € å�c�8Ñ$Ô$ð 	9àŒvŒ{˜jÐ(Ð(Ø”v—~’~ cÑ*Ô*Ð*Ø”” 
Ð*Ð*Ø”v�à8¨3¬6¬;Ð8Ð8�Ý  ‘o”oÐ%õ ˜#¥¥U˜|Ñ,Ô,ð 9°´´ÀÐ1PÐ1PÝ”y  d¤g¤l°CÑ8Ô8Ð8å”y  d¤g¤l°CÑ8Ô8Ð8r   NÚopÚstrÚim2ú_Operand | float | Noner   ú
str | Nonec                ó  — |                       |¦  «        }|€§t          j        |p|j        |j        d ¦  «        }	 t          t          |› d|j        › �¦  «        }n(# t          $ r}d|› d�}t          |¦  «        |‚d }~ww xY wt          j	        || 
                    ¦   «         | 
                    ¦   «         ¦  «         �n¿|                       |¦  «        }	|j        |	j        k    r@|j        dk    r|                     d¦  «        }|	j        dk    r|	                     d¦  «        }	|j        |	j        k    r’t          |j        d         |	j        d         ¦  «        t          |j        d         |	j        d         ¦  «        f}
|j        |
k    r|                     d|
z   ¦  «        }|	j        |
k    r|	                     d|
z   ¦  «        }	t          j        |p|j        |j        d ¦  «        }	 t          t          |› d|j        › �¦  «        }n(# t          $ r}d|› d�}t          |¦  «        |‚d }~ww xY wt          j        || 
                    ¦   «         | 
                    ¦   «         |	 
                    ¦   «         ¦  «         t          |¦  «        S )NÚ_zbad operand type for 'ú'r   r   r   )r   r   )Ú_Operand__fixupr   r#   r   r$   Úgetattrr	   ÚAttributeErrorÚ	TypeErrorÚunopÚgetimr   ÚminÚcropÚbinopr   )r   r'   r   r)   r   Úim_1ÚoutÚer%   Úim_2r$   s              r   Úapplyz_Operand.apply3   sm  € ð �|Š|˜CÑ Ô ˆØˆ;å”)˜DÐ- D¤I¨t¬y¸$Ñ?Ô?ˆCð,Ý�\¨bÐ+>Ð+>°4´9Ð+>Ð+>Ñ?Ô?��øÝ!ð ,ð ,ð ,Ø4¨rÐ4Ð4Ð4�Ý ‘n”n¨!Ð+øøøøð,øøøõ Ô˜b #§)¢)¡+¤+¨t¯zªz©|¬|Ñ<Ô<Ð<Ñ<ð —<’< Ñ$Ô$ˆDØŒy˜DœIÒ%Ð%à”9 Ò#Ð#ØŸ<š<¨Ñ,Ô,�DØ”9 Ò#Ð#ØŸ<š<¨Ñ,Ô,�DØŒy˜DœIÒ%Ð%õ ˜œ	 !œ d¤i°¤lÑ3Ô3Ý˜œ	 !œ d¤i°¤lÑ3Ô3ð�ð ”9 Ò$Ð$ØŸ9š9 V¨d¡]Ñ3Ô3�DØ”9 Ò$Ð$ØŸ9š9 V¨d¡]Ñ3Ô3�DÝ”)˜DÐ- D¤I¨t¬y¸$Ñ?Ô?ˆCð,Ý�\¨bÐ+>Ð+>°4´9Ð+>Ð+>Ñ?Ô?��øÝ!ð ,ð ,ð ,Ø4¨rÐ4Ð4Ð4�Ý ‘n”n¨!Ð+øøøøð,øøøõ Ô˜r 3§9¢9¡;¤;°·
²
±´¸d¿jºj¹l¼lÑKÔKÐKÝ˜‰}Œ}Ðs/   »A Á
B Á%A;Á;B Ç)H	 È	
H.ÈH)È)H.Úboolc                ó8   — | j                              ¦   «         d uS r   )r   Úgetbbox©r   s    r   Ú__bool__z_Operand.__bool__a   s   € àŒw�ŠÑ Ô ¨Ð,Ð,r   c                ó.   — |                       d| ¦  «        S )NÚabs©r<   r@   s    r   Ú__abs__z_Operand.__abs__e   ó   € Ø�zŠz˜% Ñ&Ô&Ð&r   c                ó   — | S r   © r@   s    r   Ú__pos__z_Operand.__pos__h   s   € Øˆr   c                ó.   — |                       d| ¦  «        S )NÚnegrD   r@   s    r   Ú__neg__z_Operand.__neg__k   rF   r   Úotherc                ó0   — |                       d| |¦  «        S ©NÚaddrD   ©r   rM   s     r   Ú__add__z_Operand.__add__o   ó   € Ø�zŠz˜%  uÑ-Ô-Ð-r   c                ó0   — |                       d|| ¦  «        S rO   rD   rQ   s     r   Ú__radd__z_Operand.__radd__r   ó   € Ø�zŠz˜% ¨Ñ-Ô-Ð-r   c                ó0   — |                       d| |¦  «        S ©NÚsubrD   rQ   s     r   Ú__sub__z_Operand.__sub__u   rS   r   c                ó0   — |                       d|| ¦  «        S rX   rD   rQ   s     r   Ú__rsub__z_Operand.__rsub__x   rV   r   c                ó0   — |                       d| |¦  «        S ©NÚmulrD   rQ   s     r   Ú__mul__z_Operand.__mul__{   rS   r   c                ó0   — |                       d|| ¦  «        S r^   rD   rQ   s     r   Ú__rmul__z_Operand.__rmul__~   rV   r   c                ó0   — |                       d| |¦  «        S ©NÚdivrD   rQ   s     r   Ú__truediv__z_Operand.__truediv__�   rS   r   c                ó0   — |                       d|| ¦  «        S rd   rD   rQ   s     r   Ú__rtruediv__z_Operand.__rtruediv__„   rV   r   c                ó0   — |                       d| |¦  «        S ©NÚmodrD   rQ   s     r   Ú__mod__z_Operand.__mod__‡   rS   r   c                ó0   — |                       d|| ¦  «        S rj   rD   rQ   s     r   Ú__rmod__z_Operand.__rmod__Š   rV   r   c                ó0   — |                       d| |¦  «        S ©NÚpowrD   rQ   s     r   Ú__pow__z_Operand.__pow__�   rS   r   c                ó0   — |                       d|| ¦  «        S rp   rD   rQ   s     r   Ú__rpow__z_Operand.__rpow__�   rV   r   c                ó.   — |                       d| ¦  «        S )NÚinvertrD   r@   s    r   Ú
__invert__z_Operand.__invert__”   s   € Ø�zŠz˜( DÑ)Ô)Ð)r   c                ó0   — |                       d| |¦  «        S ©NÚandrD   rQ   s     r   Ú__and__z_Operand.__and__—   rS   r   c                ó0   — |                       d|| ¦  «        S ry   rD   rQ   s     r   Ú__rand__z_Operand.__rand__š   rV   r   c                ó0   — |                       d| |¦  «        S ©NÚorrD   rQ   s     r   Ú__or__z_Operand.__or__�   ó   € Ø�zŠz˜$  eÑ,Ô,Ð,r   c                ó0   — |                       d|| ¦  «        S r   rD   rQ   s     r   Ú__ror__z_Operand.__ror__    s   € Ø�zŠz˜$  tÑ,Ô,Ð,r   c                ó0   — |                       d| |¦  «        S ©NÚxorrD   rQ   s     r   Ú__xor__z_Operand.__xor__£   rS   r   c                ó0   — |                       d|| ¦  «        S r†   rD   rQ   s     r   Ú__rxor__z_Operand.__rxor__¦   rV   r   c                ó0   — |                       d| |¦  «        S )NÚlshiftrD   rQ   s     r   Ú
__lshift__z_Operand.__lshift__©   ó   € Ø�zŠz˜( D¨%Ñ0Ô0Ð0r   c                ó0   — |                       d| |¦  «        S )NÚrshiftrD   rQ   s     r   Ú
__rshift__z_Operand.__rshift__¬   rŽ   r   c                ó0   — |                       d| |¦  «        S )NÚeqrD   rQ   s     r   Ú__eq__z_Operand.__eq__°   r‚   r   c                ó0   — |                       d| |¦  «        S )NÚnerD   rQ   s     r   Ú__ne__z_Operand.__ne__³   r‚   r   c                ó0   — |                       d| |¦  «        S )NÚltrD   rQ   s     r   Ú__lt__z_Operand.__lt__¶   r‚   r   c                ó0   — |                       d| |¦  «        S )NÚlerD   rQ   s     r   Ú__le__z_Operand.__le__¹   r‚   r   c                ó0   — |                       d| |¦  «        S )NÚgtrD   rQ   s     r   Ú__gt__z_Operand.__gt__¼   r‚   r   c                ó0   — |                       d| |¦  «        S )NÚgerD   rQ   s     r   Ú__ge__z_Operand.__ge__¿   r‚   r   )r   r   )r   r   r   r   )NN)
r'   r(   r   r   r)   r*   r   r+   r   r   )r   r=   )r   r   )rM   r   r   r   )&Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r/   r<   rA   rE   rI   rL   rR   rU   rZ   r\   r`   rb   rf   rh   rl   rn   rr   rt   rw   r{   r}   r�   r„   rˆ   rŠ   r�   r‘   r”   r—   rš   r�   r    r£   rH   r   r   r   r      sÐ  € € € € € Ø>Ð>ðð ð ð ð9ð 9ð 9ð 9ð, (,Øð+ð +ð +ð +ð +ð\-ð -ð -ð -ð'ð 'ð 'ð 'ðð ð ð ð'ð 'ð 'ð 'ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð.ð .ð .ð .ð*ð *ð *ð *ð.ð .ð .ð .ð.ð .ð .ð .ð-ð -ð -ð -ð-ð -ð -ð -ð.ð .ð .ð .ð.ð .ð .ð .ð1ð 1ð 1ð 1ð1ð 1ð 1ð 1ð-ð -ð -ð -ð-ð -ð -ð -ð-ð -ð -ð -ð-ð -ð -ð -ð-ð -ð -ð -ð-ð -ð -ð -ð -ð -r   r   r   r   c                óP   — t          | j                             d¦  «        ¦  «        S )Nr   ©r   r   r   r@   s    r   Úimagemath_intrª   Ä   ó   € Ý�D”G—O’O CÑ(Ô(Ñ)Ô)Ð)r   c                óP   — t          | j                             d¦  «        ¦  «        S )Nr   r©   r@   s    r   Úimagemath_floatr­   È   r«   r   rM   r*   c                ó4   — |                       d| |d¬¦  «        S )Nr“   r   ©r   rD   rQ   s     r   Úimagemath_equalr°   Í   ó   € Ø�:Š:�d˜D %¨cˆ:Ñ2Ô2Ð2r   c                ó4   — |                       d| |d¬¦  «        S )Nr–   r   r¯   rD   rQ   s     r   Úimagemath_notequalr³   Ñ   r±   r   c                ó0   — |                       d| |¦  «        S )Nr5   rD   rQ   s     r   Úimagemath_minrµ   Õ   ó   € Ø�:Š:�e˜T 5Ñ)Ô)Ð)r   c                ó0   — |                       d| |¦  «        S )NÚmaxrD   rQ   s     r   Úimagemath_maxr¹   Ù   r¶   r   r   r(   c                óP   — t          | j                             |¦  «        ¦  «        S r   r©   )r   r   s     r   Úimagemath_convertr»   Ý   s   € Ý�D”G—O’O DÑ)Ô)Ñ*Ô*Ð*r   )r!   r"   ÚequalÚnotequalr5   r¸   r   Ú
expressionúCallable[[dict[str, Any]], Any]Úoptionsúdict[str, Any]Úkwr   c                ó„  — |rt          ddd¦  «         t                               ¦   «         }|                     |¦  «         |                     |¦  «         |                     ¦   «         D ]1\  }}t          |t          j        ¦  «        rt          |¦  «        ||<   Œ2 | |¦  «        }	 |j        S # t          $ r |cY S w xY w)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.
    zImageMath.lambda_eval optionsé   z'ImageMath.lambda_eval keyword arguments)
r
   ÚopsÚcopyÚupdateÚitemsr   r   r   r   r1   )r¾   rÀ   rÂ   ÚargsÚkÚvr9   s          r   Úlambda_evalrÌ   ì   sÕ   € ð* ð 
ÝØ+ØØ5ñ	
ô 	
ð 	
õ Ÿ8š8™:œ:€DØ‡K‚K�ÑÔÐØ‡K‚K��O„O€OØ—
’
‘”ð "ð "‰ˆˆ1Ý�a�œÑ%Ô%ð 	"Ý˜q‘k”kˆD�‰Gøà
ˆ*�TÑ
Ô
€CðØŒvˆøÝð ð ð Øˆ
ˆ
ˆ
ðøøøs   Â)B0 Â0B?Â>B?c                óâ  ‡‡‡	— |rt          ddd¦  «         t                               ¦   «         Št          |                     ¦   «         ¦  «        t          |                     ¦   «         ¦  «        z   D ]0}d|v st          t          |¦  «        rd|› d�}t          |¦  «        ‚Œ1‰                     |¦  «         ‰                     |¦  «         ‰ 	                    ¦   «         D ]1\  }}t          |t          j        ¦  «        rt          |¦  «        ‰|<   Œ2t          | dd¦  «        Šdˆˆˆ	fd„Š	 ‰	‰¦  «         t          j        | ddt          ii‰¦  «        }	 |j        S # t"          $ r |cY S w xY w)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.
    zImageMath.unsafe_eval optionsrÄ   z'ImageMath.unsafe_eval keyword argumentsÚ__r.   ú' not allowedz<string>ÚevalÚcoder   r   ÚNonec                óÀ   •— | j         D ]+}t          |¦  «        t          ‰¦  «        u r ‰|¦  «         Œ,| j        D ]!}|‰vr|dk    rd|› d�}t          |¦  «        ‚Œ"d S )NrC   r.   rÏ   )Ú	co_constsÚtypeÚco_namesr    )rÑ   ÚconstÚnamer%   rÉ   Úcompiled_codeÚscans       €€€r   rÚ   zunsafe_eval.<locals>.scanD  s†   ø€ Ø”^ð 	ð 	ˆEÝ�E‰{Œ{�d =Ñ1Ô1Ð1Ð1Ø��U‘”�øà”Mð 	&ð 	&ˆDØ˜4ÐÐ D¨E¢M MØ-˜$Ð-Ð-Ð-�Ý  ‘o”oÐ%øð	&ð 	&r   Ú
__builtinsrC   N)rÑ   r   r   rÒ   )r
   rÅ   rÆ   ÚlistÚkeysÚhasattrÚbuiltinsr    rÇ   rÈ   r   r   r   ÚcompilerÐ   rC   r   r1   )
r¾   rÀ   rÂ   rÊ   r%   rË   r9   rÉ   rÙ   rÚ   s
          @@@r   Úunsafe_evalrá     sœ  øøø€ ð0 ð 
ÝØ+ØØ5ñ	
ô 	
ð 	
õ Ÿ8š8™:œ:€DÝ�'—,’,‘.”.Ñ!Ô!¥D¨¯ª©¬¡O¤OÑ3ð "ð "ˆØ�1ˆ9ˆ9�¥¨!Ñ,Ô,ˆ9Ø&�aÐ&Ð&Ð&ˆCÝ˜S‘/”/Ð!ð ð 	‡K‚K�ÑÔÐØ‡K‚K��O„O€OØ—
’
‘”ð "ð "‰ˆˆ1Ý�a�œÑ%Ô%ð 	"Ý˜q‘k”kˆD�‰Gøå˜J¨
°FÑ;Ô;€Mð&ð &ð &ð &ð &ð &ð &ð &ð 	€DˆÑÔÐÝ
Œ-˜
 \°E½3°<Ð$@À$Ñ
GÔ
G€CðØŒvˆøÝð ð ð Øˆ
ˆ
ˆ
ðøøøs   ÅE ÅE.Å-E.Ú_dictc                ó@   — t          ddd¦  «         t          | |fi |¤Ž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
    zImageMath.evalrÄ   z.ImageMath.lambda_eval or ImageMath.unsafe_eval)r
   rá   )r¾   râ   rÂ   s      r   rÐ   rÐ   V  s9   € õ* ØØ
Ø8ñô ð õ
 �z 5Ð/Ð/¨BÐ/Ð/Ð/r   )r   r   r   r   )r   r   rM   r*   r   r   )r   r   r   r(   r   r   )r¾   r¿   rÀ   rÁ   rÂ   r   r   r   )r¾   r(   rÀ   rÁ   rÂ   r   r   r   )r¾   r(   râ   rÁ   rÂ   r   r   r   )Ú
__future__r   rß   Útypesr   Útypingr   r   Ú r   r	   Ú
_deprecater
   r   rª   r­   r°   r³   rµ   r¹   r»   rÅ   rÌ   rá   rÐ   rH   r   r   ú<module>ré      s¼  ðð" #Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  à !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ø !Ð !Ð !Ð !Ð !Ð !ðe-ð e-ð e-ð e-ð e-ñ e-ô e-ð e-ðR*ð *ð *ð *ð*ð *ð *ð *ð
3ð 3ð 3ð 3ð3ð 3ð 3ð 3ð*ð *ð *ð *ð*ð *ð *ð *ð+ð +ð +ð +ð
 ØØØ"ØØØ ðð €ð !ð'ð 'ð 'ð 'ð 'ðX !ð=ð =ð =ð =ð =ðD ð0ð 0ð 0ð 0ð 0ð 0ð 0r   