
    i(                        S SK Jr  S SKrSSKJrJr  Sr\(       a  S SKJr  S SK	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SS jrSS jrg)    )annotationsN   )Image_imagingmathF)Callable)CodeType)Anyc                     \ 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-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'g)._Operand   z4Wraps an image operand, providing standard operatorsc                    Xl         g Nim)selfr   s     U/var/www/html/qgis-automation/mouza_env/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                H   U R                  U5      nUc  [        R                  " U=(       d    UR                  UR                  S 5      n [        [        U SUR                   35      n[        R                  " XR                  5       UR                  5       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 SUR                   35      n[        R                  " XR                  5       UR                  5       U	R                  5       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"   getattrr   AttributeError	TypeErrorunopgetimr   mincropbinopr   )r   opr#   im2r   im_1outer$   im_2r"   s              r   apply_Operand.apply6   s    ||C ;))D-DIItyy$?C,\bT499++>? b))+tzz|< <<$DyyDII%99#<<,D99#<<,DyyDII% 		!diil3		!diil3 99$99Vd]3D99$99Vd]3D))D-DIItyy$?C,\bT499++>? r99;

djjlK}= " ,.rd!4n!+,4 " ,.rd!4n!+,s0   I 0J  
I=&I88I= 
J!
JJ!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r9   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negrB   r=   s    r   __neg___Operand.__neg__n   rE   r   c                &    U R                  SX5      $ NaddrB   r   others     r   __add___Operand.__add__r       zz%--r   c                &    U R                  SX5      $ rO   rB   rQ   s     r   __radd___Operand.__radd__u       zz%--r   c                &    U R                  SX5      $ NsubrB   rQ   s     r   __sub___Operand.__sub__x   rU   r   c                &    U R                  SX5      $ r[   rB   rQ   s     r   __rsub___Operand.__rsub__{   rY   r   c                &    U R                  SX5      $ NmulrB   rQ   s     r   __mul___Operand.__mul__~   rU   r   c                &    U R                  SX5      $ rc   rB   rQ   s     r   __rmul___Operand.__rmul__   rY   r   c                &    U R                  SX5      $ NdivrB   rQ   s     r   __truediv___Operand.__truediv__   rU   r   c                &    U R                  SX5      $ rk   rB   rQ   s     r   __rtruediv___Operand.__rtruediv__   rY   r   c                &    U R                  SX5      $ NmodrB   rQ   s     r   __mod___Operand.__mod__   rU   r   c                &    U R                  SX5      $ rs   rB   rQ   s     r   __rmod___Operand.__rmod__   rY   r   c                &    U R                  SX5      $ NpowrB   rQ   s     r   __pow___Operand.__pow__   rU   r   c                &    U R                  SX5      $ r{   rB   rQ   s     r   __rpow___Operand.__rpow__   rY   r   c                &    U R                  SU 5      $ )NinvertrB   r=   s    r   
__invert___Operand.__invert__   s    zz(D))r   c                &    U R                  SX5      $ NandrB   rQ   s     r   __and___Operand.__and__   rU   r   c                &    U R                  SX5      $ r   rB   rQ   s     r   __rand___Operand.__rand__   rY   r   c                &    U R                  SX5      $ NorrB   rQ   s     r   __or___Operand.__or__       zz$,,r   c                &    U R                  SX5      $ r   rB   rQ   s     r   __ror___Operand.__ror__   s    zz$,,r   c                &    U R                  SX5      $ NxorrB   rQ   s     r   __xor___Operand.__xor__   rU   r   c                &    U R                  SX5      $ r   rB   rQ   s     r   __rxor___Operand.__rxor__   rY   r   c                &    U R                  SX5      $ )NlshiftrB   rQ   s     r   
__lshift___Operand.__lshift__       zz(D00r   c                &    U R                  SX5      $ )NrshiftrB   rQ   s     r   
__rshift___Operand.__rshift__   r   r   c                &    U R                  SX5      $ )NeqrB   rQ   s     r   __eq___Operand.__eq__   r   r   c                &    U R                  SX5      $ )NnerB   rQ   s     r   __ne___Operand.__ne__   r   r   c                &    U R                  SX5      $ )NltrB   rQ   s     r   __lt___Operand.__lt__   r   r   c                &    U R                  SX5      $ )NlerB   rQ   s     r   __le___Operand.__le__   r   r   c                &    U R                  SX5      $ )NgtrB   rQ   s     r   __gt___Operand.__gt__   r   r   c                &    U R                  SX5      $ )NgerB   rQ   s     r   __ge___Operand.__ge__   r   r   r   )r   Image.Image)r#   _Operand | floatreturnr   )NN)
r3   strr#   r   r4   _Operand | float | Noner   z
str | Noner   r   )r   bool)r   r   )rR   r   r   r   )(__name__
__module____qualname____firstlineno____doc__r   r*   r9   r>   rC   rH   rL   rS   rW   r]   r`   re   rh   rm   rp   ru   rx   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__rG   r   r   r   r      s    >9, (,++ + %	+
 + 
+\-''............*..--..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   rB   rQ   s     r   imagemath_equalr          ::dDc:22r   c                $    U R                  SXSS9$ )Nr   r   r   rB   rQ   s     r   imagemath_notequalr      r   r   c                &    U R                  SX5      $ )Nr0   rB   rQ   s     r   imagemath_minr          ::eT))r   c                &    U R                  SX5      $ )NmaxrB   rQ   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notequalr0   r   r   c                (   [         R                  5       nUR                  U5        UR                  5        H3  u  p4[	        U[
        R
                  5      (       d  M&  [        U5      X#'   M5     U " U5      n UR                  $ ! [         a    Us $ f = f)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 **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.
)	opscopyupdateitemsr   r   r   r   r,   )
expressionkwargskvr6   s         r   lambda_evalr      sv     88:DKKO

a%%qkDG  T
Cvv 
s   6B BBc                  ^^^ [         R                  5       mU H/  nSU;   d  [        [        U5      (       d  M   SU S3n[	        U5      e   TR                  U5        TR                  5        H4  u  p$[        U[        R                  5      (       d  M&  [        U5      TU'   M6     [        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 **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.
__r)   ' not allowedz<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 )NrA   r)   r   )	co_conststypeco_namesr   )codeconstnamer$   r   compiled_codescans       r   r   unsafe_eval.<locals>.scan+  s_    ^^EE{d=11U $ MMD4DEM$}- o% "r   
__builtinsrA   )r   r   r   None)r   r   hasattrbuiltinsr   r   r   r   r   r   compiler   rA   r   r,   )	r   r   r   r$   r   r6   r   r   r   s	         @@@r   unsafe_evalr     s    & 88:D19!,,aS&CS/! 
 	KKO

a%%qkDG  J
F;M& & 	
--
\E3<$@$
GCvv 
s   &C2 2D D)r   r   r   r   )r   r   rR   r   r   r   )r   r   r   r   r   r   )r   zCallable[[dict[str, Any]], Any]r   r	   r   r	   )r   r   r   r	   r   r	   )
__future__r   r    r   r   TYPE_CHECKINGcollections.abcr   typesr   typingr	   r   r   r   r   r   r   r   r   r   r   r   rG   r   r   <module>r     sy   " #  !(e- e-R**
33**+
 " 8/r   