
    (ph,                       S SK Jr  S SKrS SKJr  S SKJrJr  SSKJ	r	J
r
  SSKJr   " S S	5      rSS
 jrSS jrSS jrSS jrSS jrSS jrSS jr\\\\\\\S.r0 4       SS jjr0 4       SS jjr0 4       SS jjrg)    )annotationsN)CodeType)AnyCallable   )Image_imagingmath)	deprecatec                  ~   \ rS rSrSrS'S jrS(S jr  S)         S*S jjrS+S jrS,S jr	S,S	 jr
S,S
 jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS,S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jrS-S jr S  r!S! r"S-S" jr#S-S# jr$S-S$ jr%S-S% jr&S&r'g)._Operand   z4Wraps an image operand, providing standard operatorsc                    Xl         g Nim)selfr   s     @/var/www/html/venv/lib/python3.13/site-packages/PIL/ImageMath.py__init___Operand.__init__   s        c                D   [        U[        5      (       a  UR                  R                  S;   a  UR                  R	                  S5      $ UR                  R                  S;   a  UR                  $ SUR                  R                   3n[        U5      e[        U[        [        45      (       aF  U R                  R                  S;   a,  [        R                  " SU R                  R                  U5      $ [        R                  " SU R                  R                  U5      $ )N)1LI)r   Fzunsupported mode: )r   r   r   r   )
isinstancer   r   modeconvert
ValueErrorintfloatr   newsize)r   im1msgs      r   __fixup_Operand.__fixup!   s    c8$$vv{{j(vv~~c**
*vv*366;;-8 o% #U|,,1PyydggllC88yydggllC88r   Nc                   U R                  U5      nUc  [        R                  " U=(       d    UR                  UR                  S 5      nUR                  5          [        [        U SUR                   35      n[        R                  " XR                  R                  UR                  R                  5        GOU R                  U5      n	UR                  U	R                  :w  aB  UR                  S:w  a  UR                  S5      nU	R                  S:w  a  U	R                  S5      n	UR                  U	R                  :w  a  [        UR                  S   U	R                  S   5      [        UR                  S   U	R                  S   5      4n
UR                  U
:w  a  UR                  SU
-   5      nU	R                  U
:w  a  U	R                  SU
-   5      n	[        R                  " U=(       d    UR                  UR                  S 5      nUR                  5         U	R                  5          [        [        U SUR                   35      n[        R                   " XR                  R                  UR                  R                  U	R                  R                  5        [#        U5      $ ! [         a  nSU S3n[        U5      UeS nAff = f! [         a  nSU S3n[        U5      UeS nAff = f)N_zbad operand type for ''r   r   r   )r   r   )_Operand__fixupr   r"   r   r#   loadgetattrr	   AttributeError	TypeErrorunopr   idr   mincropbinopr   )r   opr$   im2r   im_1outer%   im_2r#   s              r   apply_Operand.apply3   s?    ||C ;))D-DIItyy$?CIIK,\bT499++>? b&&))TWWZZ8 <<$DyyDII%99#<<,D99#<<,DyyDII% 		!diil3		!diil3 99$99Vd]3D99$99Vd]3D))D-DIItyy$?CIIKIIK,\bT499++>? r6699dggjj$''**E}A " ,.rd!4n!+,8 " ,.rd!4n!+,s0   J* ,K *
K4KK
K/K**K/c                :    U R                   R                  5       S L$ r   )r   getbboxr   s    r   __bool___Operand.__bool__d   s    ww ,,r   c                &    U R                  SU 5      $ )Nabsr;   r?   s    r   __abs___Operand.__abs__h       zz%&&r   c                    U $ r    r?   s    r   __pos___Operand.__pos__k   s    r   c                &    U R                  SU 5      $ )NnegrD   r?   s    r   __neg___Operand.__neg__n   rG   r   c                &    U R                  SX5      $ NaddrD   r   others     r   __add___Operand.__add__r       zz%--r   c                &    U R                  SX5      $ rQ   rD   rS   s     r   __radd___Operand.__radd__u       zz%--r   c                &    U R                  SX5      $ NsubrD   rS   s     r   __sub___Operand.__sub__x   rW   r   c                &    U R                  SX5      $ r]   rD   rS   s     r   __rsub___Operand.__rsub__{   r[   r   c                &    U R                  SX5      $ NmulrD   rS   s     r   __mul___Operand.__mul__~   rW   r   c                &    U R                  SX5      $ re   rD   rS   s     r   __rmul___Operand.__rmul__   r[   r   c                &    U R                  SX5      $ NdivrD   rS   s     r   __truediv___Operand.__truediv__   rW   r   c                &    U R                  SX5      $ rm   rD   rS   s     r   __rtruediv___Operand.__rtruediv__   r[   r   c                &    U R                  SX5      $ NmodrD   rS   s     r   __mod___Operand.__mod__   rW   r   c                &    U R                  SX5      $ ru   rD   rS   s     r   __rmod___Operand.__rmod__   r[   r   c                &    U R                  SX5      $ NpowrD   rS   s     r   __pow___Operand.__pow__   rW   r   c                &    U R                  SX5      $ r}   rD   rS   s     r   __rpow___Operand.__rpow__   r[   r   c                &    U R                  SU 5      $ )NinvertrD   r?   s    r   
__invert___Operand.__invert__   s    zz(D))r   c                &    U R                  SX5      $ NandrD   rS   s     r   __and___Operand.__and__   rW   r   c                &    U R                  SX5      $ r   rD   rS   s     r   __rand___Operand.__rand__   r[   r   c                &    U R                  SX5      $ NorrD   rS   s     r   __or___Operand.__or__       zz$,,r   c                &    U R                  SX5      $ r   rD   rS   s     r   __ror___Operand.__ror__   s    zz$,,r   c                &    U R                  SX5      $ NxorrD   rS   s     r   __xor___Operand.__xor__   rW   r   c                &    U R                  SX5      $ r   rD   rS   s     r   __rxor___Operand.__rxor__   r[   r   c                &    U R                  SX5      $ )NlshiftrD   rS   s     r   
__lshift___Operand.__lshift__       zz(D00r   c                &    U R                  SX5      $ )NrshiftrD   rS   s     r   
__rshift___Operand.__rshift__   r   r   c                &    U R                  SX5      $ )NeqrD   rS   s     r   __eq___Operand.__eq__   r   r   c                &    U R                  SX5      $ )NnerD   rS   s     r   __ne___Operand.__ne__   r   r   c                &    U R                  SX5      $ )NltrD   rS   s     r   __lt___Operand.__lt__   r   r   c                &    U R                  SX5      $ )NlerD   rS   s     r   __le___Operand.__le__   r   r   c                &    U R                  SX5      $ )NgtrD   rS   s     r   __gt___Operand.__gt__   r   r   c                &    U R                  SX5      $ )NgerD   rS   s     r   __ge___Operand.__ge__   r   r   r   )r   Image.Image)r$   _Operand | floatreturnr   )NN)
r5   strr$   r   r6   _Operand | float | Noner   z
str | Noner   r   )r   bool)r   r   )rT   r   r   r   )(__name__
__module____qualname____firstlineno____doc__r   r+   r;   r@   rE   rJ   rN   rU   rY   r_   rb   rg   rj   ro   rr   rw   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__rI   r   r   r   r      s    >9, (,.. . %	.
 . 
.b-''............*..--..11------r   r   c                J    [        U R                  R                  S5      5      $ )Nr   r   r   r   r?   s    r   imagemath_intr          DGGOOC())r   c                J    [        U R                  R                  S5      5      $ )Nr   r   r?   s    r   imagemath_floatr      r   r   c                $    U R                  SXSS9$ )Nr   r   r   rD   rS   s     r   imagemath_equalr          ::dDc:22r   c                $    U R                  SXSS9$ )Nr   r   r   rD   rS   s     r   imagemath_notequalr      r   r   c                &    U R                  SX5      $ )Nr2   rD   rS   s     r   imagemath_minr          ::eT))r   c                &    U R                  SX5      $ )NmaxrD   rS   s     r   imagemath_maxr      r   r   c                J    [        U R                  R                  U5      5      $ r   r   )r   r   s     r   imagemath_convertr      s    DGGOOD)**r   )r    r!   equalnotequalr2   r   r   c                .   [         R                  5       nUR                  U5        UR                  U5        UR                  5        H%  u  pE[	        US5      (       d  M  [        U5      X4'   M'     U " U5      n UR                  $ ! [         a    Us $ f = f)ao  
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. You
                can either use a dictionary, or one or more keyword
                arguments.
: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.
r   )opscopyupdateitemshasattrr   r   r.   )
expressionoptionskwargskvr8   s          r   lambda_evalr      s~    * 88:DKKKKO

1dqkDG  T
Cvv 
s   9B BBc                p  ^^^	 [         R                  5       m[        UR                  5       5      [        UR                  5       5      -    H/  nSU;   d  [	        [
        U5      (       d  M   SU S3n[        U5      e   TR                  U5        TR                  U5        TR                  5        H&  u  p5[	        US5      (       d  M  [        U5      TU'   M(     [        U SS5      mS
UUU	4S jjm	T	" T5        [
        R                  " U SS	[        00T5      n UR                  $ ! [         a    Us $ f = f)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.  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.
__r*   ' not allowedr   z<string>evalc                   > U R                    H$  n[        U5      [        T5      L d  M  T" U5        M&     U R                   H"  nUT;  d  M  US:w  d  M  SU S3n[        U5      e   g )NrC   r*   r   )	co_conststypeco_namesr   )codeconstnamer%   r   compiled_codescans       r   r   unsafe_eval.<locals>.scan9  s_    ^^EE{d=11U $ MMD4DEM$}- o% "r   
__builtinsrC   )r   r   r   None)r   r   listkeysr   builtinsr   r   r   r   compiler   rC   r   r.   )
r   r   r   r   r%   r   r8   r   r   r   s
          @@@r   unsafe_evalr    s   2 88:D',,.!DO319!,,aS&CS/! 4
 	KKKKO

1dqkDG  J
F;M& & 	
--
\E3<$@$
GCvv 
s   D& &D54D5c                4    [        SSS5        [        X40 UD6$ )a  
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.eval   z.ImageMath.lambda_eval or ImageMath.unsafe_eval)r
   r  )r   _dictr   s      r   r   r   K  s'    * 
8
 z/B//r   )r   r   r   r   )r   r   rT   r   r   r   )r   r   r   r   r   r   )r   zCallable[[dict[str, Any]], Any]r   dict[str, Any]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   rI   r   r   <module>r     s   " #     ! !h- h-X**
33**+
 "  ! /     		 J !666 6 		6v 000 0 		0r   