
    }f$              	      R   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 ddlmZ g Zd4d5dZd6d7dZ G d d          Z G d de          Zej        dk    r ee            G d de          Zej        dk    r ee            G d de          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z G d& d'e          Zej        d(vr ej        d)          r ee            ej        d*          r ee            ej        d+          r ee            ej        d,          r ee            ej        d-          r ee            G d. d/e          Z	 d d0lmZ  ee           n# e$ r Y nw xY we d1k    r e!ej"                  d2k     r e#d3            ej$                      ej%        ej"        d                   5 Z& e# ee&gej"        d2d         R             ddd           dS # 1 swxY w Y   dS dS )8    )annotationsNquote)Any   )ImageorderintreturnNonec                    	 t          | t                    r
 |             } n# t          $ r Y nw xY w|dk    rt                              |            dS t                              d|            dS )a$  
    The :py:func:`register` function is used to register additional viewers::

        from PIL import ImageShow
        ImageShow.register(MyViewer())  # MyViewer will be used as a last resort
        ImageShow.register(MySecondViewer(), 0)  # MySecondViewer will be prioritised
        ImageShow.register(ImageShow.XVViewer(), 0)  # XVViewer will be prioritised

    :param viewer: The viewer to be registered.
    :param order:
        Zero or a negative integer to prepend this viewer to the list,
        a positive integer to append it.
    r   N)
issubclassViewer	TypeError_viewersappendinsert)viewerr	   s     F/var/www/rtfcompare/venv/lib/python3.11/site-packages/PIL/ImageShow.pyregisterr      s    ff%% 	VXXF   qyy6"""""s   " 
//imageImage.Imagetitle
str | Noneoptionsr   boolc                @    t           D ]} |j        | fd|i|r dS dS )a  
    Display a given image.

    :param image: An image object.
    :param title: Optional title. Not all viewers can display the title.
    :param \**options: Additional viewer options.
    :returns: ``True`` if a suitable viewer was found, ``False`` otherwise.
    r   TF)r   show)r   r   r   r   s       r   r   r   6   sE       6;u55E5W55 	44	5    c                  d    e Zd ZU dZddZd	Zd
ed<   	 i Zded<   	 ddZddZ	ddZ
ddZddZd	S )r   zBase class for viewers.r   r   r   r   r   r
   c                    |j         dv sM| j        dk    r	|j         dv s9t          j        |j                   }|j         |k    r|                    |          } | j        |fi |S )z
        The main function for displaying an image.
        Converts the given image to the target format and displays it.
        )1RGBAPNG)zI;16LA)modeformatr   getmodebaseconvert
show_image)selfr   r   bases       r   r   zViewer.showJ   st     J-''u$$~)E)E$UZ00DzT!!d++tu00000r   Nr   r'   zdict[str, Any]c                    | j         S )z3Return format name, or ``None`` to save as PGM/PPM.)r'   r+   r   s     r   
get_formatzViewer.get_formata   s
    {r   filestrc                $    d}t          |          )zj
        Returns the command used to display the file.
        Not implemented in the base class.
        zunavailable in base viewer)NotImplementedError)r+   r0   r   msgs       r   get_commandzViewer.get_commande   s    
 +!#&&&r   c                P     |j         dd|                     |          i| j        S )z+Save to temporary file and return filename.r'    )_dumpr/   r   r.   s     r   
save_imagezViewer.save_imagem   s-    u{II$//%"8"8IDLIIIr   c                D     | j         |                     |          fi |S )zDisplay the given image.)	show_filer9   r+   r   r   s      r   r*   zViewer.show_imageq   s(    t~dooe44@@@@@r   pathc                F    t          j         | j        |fi |           dS )%
        Display given file.
        r   )ossystemr5   r+   r=   r   s      r   r;   zViewer.show_fileu   s/     		"$"433733444qr   r   r   r   r   r   r
   )r   r   r   r   r0   r1   r   r   r   r1   )r   r   r   r1   r=   r1   r   r   r   r
   )__name__
__module____qualname____doc__r   r'   __annotations__r   r/   r5   r9   r*   r;   r7   r   r   r   r   E   s         !!1 1 1 1$ F/ G    7   ' ' ' 'J J J JA A A A     r   r   c                  0    e Zd ZdZdZdddZddZddZdS )WindowsViewerzNThe default viewer on Windows is the default system application for PNG files.r$   r   Tcompress_levelsave_allr0   r1   r   r   r   c                    d| d| dS )Nzstart "Pillow" /WAIT "z)" && ping -n 4 127.0.0.1 >NUL && del /f ""r7   r+   r0   r   s      r   r5   zWindowsViewer.get_command   s*    "T " "" " "	
r   r=   r
   c                r    t          j         | j        |fi |dt          t           d                     dS )r?   TCREATE_NO_WINDOW)shellcreationflagsr   )
subprocessPopenr5   getattrrB   s      r   r;   zWindowsViewer.show_file   sN     	DT--W--!*.@AA	
 	
 	
 	

 qr   NrD   rE   rF   rG   rH   rI   r'   r   r5   r;   r7   r   r   rL   rL      sT        XXF!"55G
 
 
 
	 	 	 	 	 	r   rL   win32c                  0    e Zd ZdZdZdddZddZddZdS )	MacViewerz2The default viewer on macOS using ``Preview.app``.r$   r   TrM   r0   r1   r   r   r   c                V    d}d| dt          |           dt          |           d}|S )Nzopen -a Preview.app( z; sleep 20; rm -f z)&r   r+   r0   r   commands       r   r5   zMacViewer.get_command   s:     (NgNNdNNuT{{NNNr   r=   r
   c                    t          j        ddd|g           t          j        pt	          j        d          }|rt          j        |dd|g           dS )r?   openz-azPreview.apppython3z-cz<import os, sys, time; time.sleep(20); os.remove(sys.argv[1])r   )rW   callsys
executableshutilwhichrX   )r+   r=   r   rh   s       r   r;   zMacViewer.show_file   sh     	}d;<<<^>v|I'>'>
 	R	   qr   NrD   rE   rZ   r7   r   r   r]   r]      sT        <<F!"55G        r   r]   darwinc                  F    e Zd ZdZdddZej        dd            ZddZdS )
UnixViewerr$   r   TrM   r0   r1   r   r   r   tuple[str, str]c                    d S Nr7   rR   s      r   get_command_exzUnixViewer.get_command_ex   s    r   c                T     | j         |fi |d         }d| dt          |           S )Nr   r_   r`   )rq   r   ra   s       r   r5   zUnixViewer.get_command   s=    %$%d66g66q9*7**U4[[***r   Nr0   r1   r   r   r   rn   rD   )	rF   rG   rH   r'   r   abcabstractmethodrq   r5   r7   r   r   rm   rm      s\        F!"55G   + + + + + +r   rm   c                  "    e Zd ZdZddZddZdS )	XDGViewerz3
    The freedesktop.org ``xdg-open`` command.
    r0   r1   r   r   r   rn   c                    dx}}||fS )Nxdg-openr7   )r+   r0   r   rb   rh   s        r   rq   zXDGViewer.get_command_ex   s    ))*
""r   r=   r
   c                2    t          j        d|g           dS )r?   ry   r   rW   rX   rB   s      r   r;   zXDGViewer.show_file   s     	*d+,,,qr   Nrs   rE   rF   rG   rH   rI   rq   r;   r7   r   r   rw   rw      sF         # # # #     r   rw   c                  &    e Zd ZdZ	 dddZddZdS )DisplayViewerz`
    The ImageMagick ``display`` command.
    This viewer supports the ``title`` parameter.
    Nr0   r1   r   r   r   r   r   rn   c                @    dx}}|r|dt          |           z  }||fS )Ndisplayz -title r   r+   r0   r   r   rb   rh   s         r   rq   zDisplayViewer.get_command_ex   s:      )(* 	10%,,000G
""r   r=   r
   c                    dg}|                     d          }|r|d|gz  }|                    |           t          j        |           dS )r?   r   r   z-titler   getr   rW   rX   r+   r=   r   argsr   s        r   r;   zDisplayViewer.show_file   s[     {G$$ 	&Xu%%DDqr   rp   r0   r1   r   r   r   r   r   rn   rE   r|   r7   r   r   r~   r~      sP          .2# # # # #     r   r~   c                  "    e Zd ZdZddZddZdS )GmDisplayViewerz*The GraphicsMagick ``gm display`` command.r0   r1   r   r   r   rn   c                    d}d}||fS )Ngmz
gm displayr7   r+   r0   r   rh   rb   s        r   rq   zGmDisplayViewer.get_command_ex   s    

""r   r=   r
   c                4    t          j        dd|g           dS )r?   r   r   r   r{   rB   s      r   r;   zGmDisplayViewer.show_file  s!     	$	40111qr   Nrs   rE   r|   r7   r   r   r   r      sB        44# # # #
     r   r   c                  "    e Zd ZdZddZddZdS )	EogViewerz'The GNOME Image Viewer ``eog`` command.r0   r1   r   r   r   rn   c                    d}d}||fS )Neogzeog -nr7   r   s        r   rq   zEogViewer.get_command_ex  s    

""r   r=   r
   c                4    t          j        dd|g           dS )r?   r   z-nr   r{   rB   s      r   r;   zEogViewer.show_file  s!     	%t,---qr   Nrs   rE   r|   r7   r   r   r   r   
  sB        11# # # #
     r   r   c                  &    e Zd ZdZ	 dddZddZdS )XVViewerzX
    The X Viewer ``xv`` command.
    This viewer supports the ``title`` parameter.
    Nr0   r1   r   r   r   r   r   rn   c                @    dx}}|r|dt          |           z  }||fS )Nxvz -name r   r   s         r   rq   zXVViewer.get_command_ex   s:    
  $#* 	0/u///G
""r   r=   r
   c                    dg}|                     d          }|r|d|gz  }|                    |           t          j        |           dS )r?   r   r   z-namer   r   r   s        r   r;   zXVViewer.show_file*  s[     vG$$ 	%We$$DDqr   rp   r   rE   r|   r7   r   r   r   r     sP          .2# # # # #     r   r   )r[   rk   ry   r   r   r   r   c                      e Zd ZdZd
dZd	S )IPythonViewerz!The viewer for IPython frontends.r   r   r   r   r   r
   c                $    t          |           dS )Nr   )ipython_displayr<   s      r   r*   zIPythonViewer.show_imageH  s    qr   NrC   )rF   rG   rH   rI   r*   r7   r   r   r   r   E  s.        ++     r   r   )r   __main__   z.Syntax: python3 ImageShow.py imagefile [title])r   )r	   r
   r   r   rp   )r   r   r   r   r   r   r   r   )'
__future__r   rt   r@   ri   rW   rg   shlexr   typingr    r   r   r   r   r   rL   platformr]   rm   rw   r~   r   r   r   rj   r   IPython.displayr   r   ImportErrorrF   lenargvprintexitrd   imr7   r   r   <module>r      s   # " " " " " 



 				      



                  # # # # #2    5 5 5 5 5 5 5 5v    F   2 <7H]       > <8HY
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+    
   "    J   8    j        
        z   < <***v|J v|I  v|D "!!!v|E v|D     F   :::::: H]  	 	 	D	 z
s38}}q>???


	CHQK	 	  'Bdd2%%%%&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' s$   F FF- HH!H