zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
U
T±d%.ã    @s$ddlZddlZddlZddlZddlmZddlmZddlm    Z    gZ
d*dd„Z d+dd    „Z Gd
d „d ƒZ Gd d „d e ƒZejdkrŒe eƒGdd„de ƒZejdkr®e eƒGdd„de ƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZejdkr~e d¡r.e eƒe d ¡rBe eƒe d!¡rVe eƒe d"¡rje eƒe d#¡r~e eƒGd$d%„d%e ƒZzdd&lmZWnek
r´Yn
Xe eƒed'kr eejƒd(krèe d)ƒe !¡e "ejd¡"Z#e e e#fejd(d…žŽƒW5QRXdS),éN©Úquote)ÚImageé)Ú    deprecatecCsNzt|tƒr|ƒ}Wntk
r(YnX|dkr>t |¡n t d|¡dS)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.
    rN)Ú
issubclassÚViewerÚ    TypeErrorÚ_viewersÚappendÚinsert)ÚviewerÚorder©rúDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PIL/ImageShow.pyÚregisters
 
 rcKs*tD] }|j|fd|i|—ŽrdSqdS)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.
    ÚtitleTF)r
Úshow)ÚimagerÚoptionsr rrrr4s    rc@sJeZdZdZdd„ZdZiZdd„Zdd„Zd    d
„Z    d d „Z
dd d„Z dS)rzBase class for viewers.cKsL|jdks>|jdkr|jdks>t |j¡}|j|kr>| |¡}|j|f|ŽS)zƒ
        The main function for displaying an image.
        Converts the given image to the target format and displays it.
        )Ú1ZRGBAÚPNG)zI;16ZLA)ÚmodeÚformatrZ getmodebaseÚconvertÚ
show_image)ÚselfrrÚbaserrrrHsÿþþ 
 
z Viewer.showNcCs|jS)z3Return format name, or ``None`` to save as PGM/PPM.)r©rrrrrÚ
get_format_szViewer.get_formatcKst‚dS)zj
        Returns the command used to display the file.
        Not implemented in the base class.
        N)ÚNotImplementedError©rÚfilerrrrÚ get_commandcszViewer.get_commandcCs|jfd| |¡i|j—ŽS)z+Save to temporary file and return filename.r)Ú_dumprrrrrrÚ
save_imagejszViewer.save_imagecKs|j| |¡f|ŽS)zDisplay the given image.)Ú    show_filer%©rrrrrrrnszViewer.show_imagecKsL|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚t |j|f|Ž¡dS)úà
        Display given file.
 
        Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
        and will be removed in Pillow 10.0.0 (2023-07-01). ``path`` should be used
        instead.
        Nr"úThe 'file' argumenté
ú'path'ú!Missing required argument: 'path'r)rÚpopr    ÚosÚsystemr#©rÚpathrÚmsgrrrr&rs  zViewer.show_file)N) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrr#r%rr&rrrrrCsrc@s&eZdZdZdZdddœZdd„ZdS)    Ú WindowsViewerzNThe default viewer on Windows is the default system application for PNG files.rrT©Zcompress_levelZsave_allcKsd|›d|›dS)Nzstart "Pillow" /WAIT "z)" && ping -n 4 127.0.0.1 >NUL && del /f "ú"rr!rrrr#ŽsÿzWindowsViewer.get_commandN)r3r4r5r6rrr#rrrrr7ˆs
r7Úwin32c@s0eZdZdZdZdddœZdd„Zd d    d
„ZdS) Ú    MacViewerz2The default viewer on macOS using ``Preview.app``.rrTr8cKs(d}d|›dt|ƒ›dt|ƒ›d}|S)Nzopen -a Preview.appú(ú z; sleep 20; rm -f z)&r©rr"rÚcommandrrrr# s zMacViewer.get_commandNcKsp|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚t ddd    |g¡tjpTt d
¡}|rlt     |d d |g¡d S)r(Nr"r)r*r+r,Úopenz-az Preview.appZpython3z-cz<import os, sys, time; time.sleep(20); os.remove(sys.argv[1])r)
rr-r    Ú
subprocessÚcallÚsysÚ
executableÚshutilÚwhichÚPopen)rr1rr2rDrrrr&§s"  üÿzMacViewer.show_file)N)r3r4r5r6rrr#r&rrrrr;šs
 
r;Údarwinc@s"eZdZdZdddœZdd„ZdS)Ú
UnixViewerrrTr8cKs&|j|f|Žd}d|›dt|ƒ›S)Nrr<r=)Úget_command_exrr>rrrr#ÌszUnixViewer.get_commandN)r3r4r5rrr#rrrrrIÈs
rIc@s"eZdZdZdd„Zddd„ZdS)Ú    XDGViewerz3
    The freedesktop.org ``xdg-open`` command.
    cKsd}}||fS)Núxdg-openr)rr"rr?rDrrrrJÖszXDGViewer.get_command_exNcKsF|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚t d|g¡dS)    r(Nr"r)r*r+r,rLr©rr-r    rArGr0rrrr&Ús  zXDGViewer.show_file)N©r3r4r5r6rJr&rrrrrKÑsrKc@s$eZdZdZddd„Zddd„ZdS)    Ú DisplayViewerz`
    The ImageMagick ``display`` command.
    This viewer supports the ``title`` parameter.
    NcKs&d}}|r|dt|ƒ›7}||fS)NÚdisplayz -title r©rr"rrr?rDrrrrJószDisplayViewer.get_command_excKsl|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚dg}| d¡}|rT|d    |g7}| |¡t |¡d
S) ú©
        Display given file.
 
        Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
        and ``path`` should be used instead.
        Nr"r)r*r+r,rPrz-titler©rr-r    Úgetr rArG©rr1rr2Úargsrrrrr&ùs  
 
 
zDisplayViewer.show_file)N)NrNrrrrrOís
rOc@s"eZdZdZdd„Zddd„ZdS)ÚGmDisplayViewerz*The GraphicsMagick ``gm display`` command.cKsd}d}||fS)NÚgmz
gm displayr©rr"rrDr?rrrrJszGmDisplayViewer.get_command_exNcKsH|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚t dd|g¡d    S)
rRNr"r)r*r+r,rXrPrrMr0rrrr&s  zGmDisplayViewer.show_file)NrNrrrrrWsrWc@s"eZdZdZdd„Zddd„ZdS)Ú    EogViewerz'The GNOME Image Viewer ``eog`` command.cKsd}d}||fS)NÚeogzeog -nrrYrrrrJ.szEogViewer.get_command_exNcKsH|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚t dd|g¡d    S)
rRNr"r)r*r+r,r[z-nrrMr0rrrr&3s  zEogViewer.show_file)NrNrrrrrZ+srZc@s$eZdZdZddd„Zddd„ZdS)    ÚXVViewerzX
    The X Viewer ``xv`` command.
    This viewer supports the ``title`` parameter.
    NcKs&d}}|r|dt|ƒ›7}||fS)NÚxvz -name rrQrrrrJKszXVViewer.get_command_excKsl|dkr4d|kr(tdddƒ| d¡}n d}t|ƒ‚dg}| d¡}|rT|d    |g7}| |¡t |¡d
S) rRNr"r)r*r+r,r]rz-namerrSrUrrrr&Ss  
 
 
zXVViewer.show_file)N)NrNrrrrr\Es
r\)r:rHrLrPrXr[r]c@seZdZdZdd„ZdS)Ú IPythonViewerz!The viewer for IPython frontends.cKs t|ƒdS)Nr)Úipython_displayr'rrrr{szIPythonViewer.show_imageN)r3r4r5r6rrrrrr^xsr^)rPÚ__main__éz.Syntax: python3 ImageShow.py imagefile [title])r)N)$r.rErArCÚshlexrZPILrZ
_deprecaterr
rrrr7Úplatformr;rIrKrOrWrZr\rFr^ZIPython.displayrPr_Ú ImportErrorr3ÚlenÚargvÚprintÚexitr@ZimrrrrÚ<module>sZ   
 
E
*
    $&