+
     i.  c                  s   ^ RI Ht ^ RIt^ RIHt ^ RIHtHt ^RIH	t	H
t
 ^RIHt  ! R R4      tR	 R
 ltR R ltR R ltR R ltR R ltR R ltR R ltR]R]R]R]R]R]R]/t/ 3R R llt/ 3R  R! llt/ 3R" R# lltR# )$    )annotationsN)CodeType)AnyCallable)Image_imagingmath)	deprecatec                  s   ] tR t^tRtR R ltR R ltRHR R lltR	 R
 ltR R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R  ltR! R" ltR# R$ ltR% R& ltR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltR5 R6 ltR7 R8 ltR9 R: lt R; R< lt!R= R> lt"R? R@ lt#RA RB lt$RC RD lt%RE RF lt&RGt'R# )I_Operandz4Wraps an image operand, providing standard operatorsc                   V ^8  d   QhRR/# )   imImage.Image Zformat   "4/usr/lib64/python3.14/site-packages/PIL/ImageMath.py__annotate___Operand.__annotate__   s      ;     c                	s    Wn         R # Nr   )selfr      &&r   __init__Z_Operand.__init__   s    r   c                    V ^8  d   QhRRRR/# )r
   im1_Operand | floatreturnr   r   r   r   r   r   r   !   s     9 9+ 9 9r   c                	sN   \        V\        4      '       d   VP                  P                  R9   d   VP                  P	                  R4      # VP                  P                  R9   d   VP                  # RVP                  P                   2p\        V4      h\        V\        \        34      '       dH   V P                  P                  R9   d-   \        P                  ! RV P                  P                  V4      # \        P                  ! RV P                  P                  V4      # )1IFzunsupported mode: )r   L)r   r   )r   r    r   )
isinstancer   r   modeconvert
ValueErrorintfloatr   newsize)r   r   msgs   && r   Z__fixupZ_Operand.__fixup!   s    c8$$vv{{j(vv~~c**
*vv*366;;-8 o% #U|,,1PyydggllC88yydggllC88r   Nc          
     s,    V ^8  d   QhRRRRRRRRR	R
/# )r
   opstrr   r   im2_Operand | float | Noner"   z
str | Noner   r   r   r   r   r   r   r   3   s<     + ++ + %	+
 + 
+r   c                	s   V P                  V4      pVf   \        P                  ! T;'       g    VP                  VP                  R 4      p \        \        V RVP                   24      p\        P                  ! YP                  4       TP                  4       4       EMV P                  V4      p	VP                  V	P                  8w  dE   VP                  R8w  d   VP                  R4      pV	P                  R8w  d   V	P                  R4      p	VP                  V	P                  8w  d   \        VP                  ^ ,          V	P                  ^ ,          4      \        VP                  ^,          V	P                  ^,          4      3p
VP                  V
8w  d   VP                  RV
,           4      pV	P                  V
8w  d   V	P                  RV
,           4      p	\        P                  ! T;'       g    VP                  VP                  R 4      p \        \        V RVP                   24      p\        P                  ! YP                  4       TP                  4       T	P                  4       4       \        T4      #   \         d   pRT R2p\        T4      ThR p?ii ; i  \         d   pRT R2p\        T4      ThR p?ii ; i)NZ_zbad operand type for ''r   )r    r    )_Operand__fixupr   r'   r"   r(   Zgetattrr   AttributeErrorZ	TypeErrorZunopZgetimr#   minZcropZbinopr   )r   r*   r   r,   r"   Zim_1outZer)   Zim_2r(   s   &&&&&      r   applyZ_Operand.apply3   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= J" =JJJ"K-J??Kc               r	   )r
   r   Zboolr   r   r   r   r   r   a   s     - -$ -r   c                	s:    V P                   P                  4       R J# r   )r   Zgetbboxr      &r   __bool__Z_Operand.__bool__a   s    ww ,,r   c               r	   r
   r   r   r   r   r   r   r   r   e        ' ' 'r   c                	&    V P                  R V 4      # )absr3   r4   r5   r   __abs__Z_Operand.__abs__e       zz%&&r   c               r	   r7   r   r   r   r   r   r   h   s       r   c                	s    V # r   r   r4   r5   r   __pos__Z_Operand.__pos__h   s    r   c               r	   r7   r   r   r   r   r   r   k   r8   r   c                	r9   )Znegr;   r4   r5   r   __neg__Z_Operand.__neg__k   r=   r   c               r   r
   otherr   r   r   r   r   r   r   r   r   o        . .- .( .r   c                	&    V P                  R W4      # Zaddr;   r   rA   r   r   __add__Z_Operand.__add__o       zz%--r   c               r   r@   r   r   r   r   r   r   r        . .. .8 .r   c                	&    V P                  R W4      # rD   r;   rE   r   r   __radd__Z_Operand.__radd__r       zz%--r   c               r   r@   r   r   r   r   r   r   u   rB   r   c                	rC   Zsubr;   rE   r   r   __sub__Z_Operand.__sub__u   rG   r   c               r   r@   r   r   r   r   r   r   x   rH   r   c                	rI   rL   r;   rE   r   r   __rsub__Z_Operand.__rsub__x   rK   r   c               r   r@   r   r   r   r   r   r   {   rB   r   c                	rC   Zmulr;   rE   r   r   __mul__Z_Operand.__mul__{   rG   r   c               r   r@   r   r   r   r   r   r   ~   rH   r   c                	rI   rO   r;   rE   r   r   __rmul__Z_Operand.__rmul__~   rK   r   c               r   r@   r   r   r   r   r   r      s     . .!1 .h .r   c                	rC   Zdivr;   rE   r   r   __truediv__Z_Operand.__truediv__   rG   r   c               r   r@   r   r   r   r   r   r      s     . ."2 .x .r   c                	rI   rR   r;   rE   r   r   __rtruediv__Z_Operand.__rtruediv__   rK   r   c               r   r@   r   r   r   r   r   r      rB   r   c                	rC   Zmodr;   rE   r   r   __mod__Z_Operand.__mod__   rG   r   c               r   r@   r   r   r   r   r   r      rH   r   c                	rI   rU   r;   rE   r   r   __rmod__Z_Operand.__rmod__   rK   r   c               r   r@   r   r   r   r   r   r      rB   r   c                	rC   Zpowr;   rE   r   r   __pow__Z_Operand.__pow__   rG   r   c               r   r@   r   r   r   r   r   r      rH   r   c                	rI   rX   r;   rE   r   r   __rpow__Z_Operand.__rpow__   rK   r   c               r	   r7   r   r   r   r   r   r      s     * *H *r   c                	r9   )Zinvertr;   r4   r5   r   
__invert__Z_Operand.__invert__   s    zz(D))r   c               r   r@   r   r   r   r   r   r      rB   r   c                	rC   Zandr;   rE   r   r   __and__Z_Operand.__and__   rG   r   c               r   r@   r   r   r   r   r   r      rH   r   c                	rI   r\   r;   rE   r   r   __rand__Z_Operand.__rand__   rK   r   c               r   r@   r   r   r   r   r   r           - -, - -r   c                	rC   Zorr;   rE   r   r   __or__Z_Operand.__or__       zz$,,r   c               r   r@   r   r   r   r   r   r      s     - -- -( -r   c                	rI   r`   r;   rE   r   r   __ror__Z_Operand.__ror__   s    zz$,,r   c               r   r@   r   r   r   r   r   r      rB   r   c                	rC   Zxorr;   rE   r   r   __xor__Z_Operand.__xor__   rG   r   c               r   r@   r   r   r   r   r   r      rH   r   c                	rI   rd   r;   rE   r   r   __rxor__Z_Operand.__rxor__   rK   r   c               r   r@   r   r   r   r   r   r           1 1 0 1X 1r   c                	rC   )Zlshiftr;   rE   r   r   
__lshift__Z_Operand.__lshift__       zz(D00r   c               r   r@   r   r   r   r   r   r      rg   r   c                	rC   )Zrshiftr;   rE   r   r   
__rshift__Z_Operand.__rshift__   ri   r   c               r   r@   r   r   r   r   r   r      r_   r   c                	rC   )eqr;   rE   r   r   __eq__Z_Operand.__eq__   rb   r   c               r   r@   r   r   r   r   r   r      r_   r   c                	rC   )ner;   rE   r   r   __ne__Z_Operand.__ne__   rb   r   c               r   r@   r   r   r   r   r   r      r_   r   c                	rC   )Zltr;   rE   r   r   __lt__Z_Operand.__lt__   rb   r   c               r   r@   r   r   r   r   r   r      r_   r   c                	rC   )Zler;   rE   r   r   __le__Z_Operand.__le__   rb   r   c               r   r@   r   r   r   r   r   r      r_   r   c                	rC   )Zgtr;   rE   r   r   __gt__Z_Operand.__gt__   rb   r   c               r   r@   r   r   r   r   r   r      r_   r   c                	rC   )Zger;   rE   r   r   __ge__Z_Operand.__ge__   rb   r   r   )NN)(Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r   r/   r3   r6   r<   r>   r?   rF   rJ   rM   rN   rP   rQ   rS   rT   rV   rW   rY   rZ   r[   r]   r^   ra   rc   re   rf   rh   rj   rl   rn   ro   rp   rq   rr   Z__static_attributes__r   r   r   r   r      s    >9$+\-''............*..--..11------ -r   r   c                    V ^8  d   QhRRRR/# r
   r   r   r   r   r   r   r   r   r      s     * * *X *r   c                J    \        V P                  P                  R 4      4      # )r   r   r   r#   r4   r5   r   imagemath_intrw          DGGOOC())r   c               rs   rt   r   r   r   r   r   r      s     * *( *x *r   c                ru   )r   rv   r4   r5   r   imagemath_floatry      rx   r   c               $    V ^8  d   QhRRRRRR/# r
   r   r   rA   r-   r   r   r   r   r   r   r      s"     3 3( 3+B 3x 3r   c                *    V P                  R WRR7      # )rk   r   r"   r;   rE   r   r   imagemath_equalr~          ::dDc:22r   c               rz   r{   r   r   r   r   r   r      s"     3 3X 3.E 3( 3r   c                r|   )rm   r   r}   r;   rE   r   r   imagemath_notequalr      r   r   c               rz   r{   r   r   r   r   r   r      "     * * *)@ *X *r   c                rC   )r1   r;   rE   r   r   imagemath_minr          ::eT))r   c               rz   r{   r   r   r   r   r   r      r   r   c                rC   )maxr;   rE   r   r   imagemath_maxr      r   r   c               rz   )r
   r   r   r"   r+   r   r   r   r   r   r   r      s!     + +H +C +H +r   c                sJ    \        V P                  P                  V4      4      # r   rv   )r   r"   r   r   imagemath_convertr      s    DGGOOD)**r   r%   r&   ZequalZnotequalr1   r   r#   c               (    V ^8  d   QhRRRRRRRR/# )r
   
expressionzCallable[[dict[str, Any]], Any]optionsdict[str, Any]kwr   r   r   r   r   r   r   r      s0     ' '/'' ' 		'r   c                sx   V'       d   \        R^R4       \        P                  4       pVP                  V4       VP                  V4       VP	                  4        F4  w  rE\        V\        P                  4      '       g   K'  \        V4      W4&   K6  	  V ! V4      p VP                  #   \         d    Tu # i ; i)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 optionsz'ImageMath.lambda_eval keyword arguments)
r   opscopyupdateitemsr!   r   r   r   r0   )r   r   r   argskvr2   s   &&,    r   lambda_evalr      s    * +5	
 88:DKKKKO

a%%qkDG  T
Cvv 
s   B) )B98B9c               r   )r
   r   r+   r   r   r   r   r   r   r   r   r   r   r     s0     = === = 		=r   c                sf  aaa	 V'       d   \        R^R4       \        P                  4       o. VOVO F1  pRV9   g   \        \        V4      '       g   K"  RV R2p\        V4      h	  SP                  V4       SP                  V4       SP                  4        F5  w  r5\        V\        P                  4      '       g   K'  \        V4      SV&   K7  	  \        V RR4      oR VVV	3R	 llo	S	! S4       \        P                  ! V R
R\        //S4      p VP                  #   \         d    Tu # i ; i)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 optionsz'ImageMath.unsafe_eval keyword argumentsZ__r.   ' not allowedz<string>evalc               r   )r
   coder   r   ZNoner   r   r   r   r   Z!unsafe_eval.<locals>.__annotate__D  s     & &8 & &r   c                s   < V P                    F%  p\        V4      \        S4      J g   K  S! V4       K'  	  V P                   F$  pVS9  g   K  VR 8w  g   K  RV R2p\        V4      h	  R# )r:   r.   r   N)Z	co_constsZtypeZco_namesr$   )r   ZconstZnamer)   r   compiled_codescans   &   r   r   Zunsafe_eval.<locals>.scanD  s_    ^^EE{d=11U $ MMD4DEM$}- o% "r   Z
__builtinsr:   )r   r   r   Zhasattrbuiltinsr$   r   r   r!   r   r   Zcompiler   r:   r   r0   )
r   r   r   r   r)   r   r2   r   r   r   s
   &&,    @@@r   unsafe_evalr     s   0 +5	
 88:Dw__19!,,aS&CS/! 
 	KKKKO

a%%qkDG  J
F;M& & 	
--
\E3<$@$
GCvv 
s   D   D0/D0c               r   )r
   r   r+   _dictr   r   r   r   r   r   r   r   r   r   V  s0     0 000 0 		0r   c                s4    \        R^R4       \        W3/ VB # )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.evalz.ImageMath.lambda_eval or ImageMath.unsafe_eval)r   r   )r   r   r   s   &&,r   r   r   V  s'    * 
8
 z/B//r   )Z
__future__r   r   Ztypesr   Ztypingr   r   Z r   r   Z
_deprecater   r   rw   ry   r~   r   r   r   r   r   r   r   r   r   r   r   <module>r      s   " #     ! !e- e-R**
33**+
 
=__"	=	=  !'X !=D 0 0r   