Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
ImageShow.cpython-313.pyc94 linesDownload Raw Back to __pycache__
1�

2v�j�(�	�n�SSKJr SSKrSSKrSSKrSSKrSSKrSSKJr SSK	J3r4 SSKJr /r
S)S*SjjrS+S,Sjjr"S	S55r"SS\5r\R$S
:Xa\"\5 "SS\5r\R$S:Xa\"\5 "SS\R(\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS\5r\R$S;a�\R6"S5(a\"\5 \R6"S5(a\"\5 \R6"S 5(a\"\5 \R6"S!5(a\"\5 \R6"S"5(a\"\5 "S#S$\5rSS%KJr \"\5 \!S&:Xat\""\RF5S':a\$"S(5 \RJ"5 \RL"\RFS5r'\$"\"\'/\RFS'SQ765 SSS5 gg!\ a N�f=f!,(df   g=f)-�)�annotationsN��quote)�Any�)�Imagec���[U[5(a[U[5(aU"5nUS:�a[RU5 g[R
SU5 g)a�6The :py:func:`register` function is used to register additional viewers::7 8    from PIL import ImageShow9    ImageShow.register(MyViewer())  # MyViewer will be used as a last resort10    ImageShow.register(MySecondViewer(), 0)  # MySecondViewer will be prioritised11    ImageShow.register(ImageShow.XVViewer(), 0)  # XVViewer will be prioritised12 13:param viewer: The viewer to be registered.14:param order:15    Zero or a negative integer to prepend this viewer to the list,16    a positive integer to append it.17rN)�18isinstance�type�19issubclass�Viewer�_viewers�append�insert)�viewer�orders  �SD:\code\apps\devtools\python\user_packages\Python313\site-packages\PIL/ImageShow.py�registerrsE���&�$���J�v�v�$>�$>�����q�y����������6�"�c�V�[HnUR"U4SU0UD6(dM g g)z�20Display a given image.21 22:param image: An image object.23:param title: Optional title. Not all viewers can display the title.24:param \**options: Additional viewer options.25:returns: ``True`` if a suitable viewer was found, ``False`` otherwise.26�titleTF)r�show)�imager�optionsrs    rrr3s/�����;�;�u�5�E�5�W�5�5���rc�v�\rSrSr%SrSSjrSrS\S'0rS\S'SS	jr	SS27jr28SSjrSSjrSS
jr
Srg)r
�BzBase class for viewers.rc�29�URS;daURS:XaURS;dA[R"UR5nURU:waUR	U5nUR30"U40UD6$)zk31The main function for displaying an image.32Converts the given image to the target format and displays it.33)�1�RGBA�PNG)zI;16�LA)�mode�formatr�getmodebase�convert�34show_image)�selfrr�bases    rr�Viewer.showGsi��
�J�J�-�'����u�$����~�)E��$�$�U�Z�Z�0�D��z�z�T�!��
�
�d�+�����u�0��0�0rN�35str | Noner#zdict[str, Any]c��UR$)z3Return format name, or ``None`` to save as PGM/PPM.)r#�r'rs  r�36get_format�Viewer.get_format^s���{�{�rc��Sn[U5e)zR37Returns the command used to display the file.38Not implemented in the base class.39zunavailable in base viewer)�NotImplementedError)r'�filer�msgs    r�get_command�Viewer.get_commandbs��40+��!�#�&�&rc�\�UR"SSURU50URD6$)z+Save to temporary file and return filename.r#�)�_dumpr-rr,s  r�41save_image�Viewer.save_imagejs&���{�{�I�$�/�/�%�"8�I�D�L�L�I�Irc�F�UR"URU540UD6$)zDisplay the given image.)�	show_filer8�r'rrs   rr&�Viewer.show_imagens���~�~�d�o�o�e�4�@��@�@rc��[RRU5(d[e[R"UR42"U40UD65 g)�43Display given file.44r)�os�path�exists�FileNotFoundError�systemr3�r'rArs   rr;�Viewer.show_filers<���w�w�~�~�d�#�#�#�#�45�	�	�$�"�"�4�3�7�3�4�rr6�r�Image.Imagerr�return�int)rrHrIr*�r1�strrrrIrL)rrHrIrL�rArLrrrIrJ)�__name__�46__module__�__qualname__�__firstlineno__�__doc__rr#�__annotations__rr-r3r8r&r;�__static_attributes__r6rrr
r
BsA��!�1�$�F�J��/� �G�^� �7��'�J�A�rr
c�:�\rSrSrSrSrSSS.rSSjrSSjrS	r	g47)
�
WindowsViewer�zNThe default viewer on Windows is the default system application for PNG files.r rT��compress_level�save_allc��SUSUS3$)Nzstart "Pillow" /WAIT "z)" && ping -n 4 127.0.0.1 >NUL && del /f "�"r6�r'r1rs   rr3�WindowsViewer.get_command�s��$�T�F�+���q�
"�	48rc���[RRU5(d[e[R49"UR"U40UD6S[[S5S9 g)r?T�CREATE_NO_WINDOW)�shell�
creationflagsr)r@rArBrC�50subprocess�Popenr3�getattrrEs   rr;�WindowsViewer.show_file�sQ���w�w�~�~�d�#�#�#�#�������T�-�W�-��!�*�.@�A�	51�52rr6NrKrM�53rNrOrPrQrRr#rr3r;rTr6rrrVrVs��X�
�F�!"��5�G�54�rrV�win32c�:�\rSrSrSrSrSSS.rSSjrSSjrS	r	g55)
�	MacViewer�z2The default viewer on macOS using ``Preview.app``.r rTrXc�F�SnSUS[U5S[U5S3nU$)Nzopen -a Preview.app�(� z; sleep 20; rm -f z)&r�r'r1r�commands    rr3�MacViewer.get_command�s1��(���g�Y�a��d��}�,>�u�T�{�m�2�N���rc��[RRU5(d[e[R56"SSSU/5 [
[SS5=(a [[S5nU(+=(a [R=(d [R"S5nU(a[R"USS	U/5 g57)r?�openz-azPreview.app�frozenF�_MEIPASS�python3z-cz<import os, sys, time; time.sleep(20); os.remove(sys.argv[1])r)
r@rArBrCrc�callre�sys�hasattr�58executable�shutil�whichrd)r'rAr�pyinstallerrzs     rr;�MacViewer.show_file�s����w�w�~�~�d�#�#�#�#������}�d�;�<��c�8�U�3�P���Z�8P��%�o�8�#�.�.�T�V�\�\�)�=T�59�������R��	�
�rr6NrKrMrgr6rrrjrj�s��<�
�F�!"��5�G��rrj�darwinc�T�\rSrSrSrSSS.r\RS60Sj5rSSjr	Sr61g	)�62UnixViewer��r rTrXc��g�Nr6r]s   r�get_command_ex�UnixViewer.get_command_ex�s��rc�N�UR"U40UD6SnUS[U53$)Nrrn)r�rros    rr3�UnixViewer.get_command�s1���%�%�d�6�g�6�q�9����!�E�$�K�=�)�)rr6N�r1rLrrrI�tuple[str, str]rK)rNrOrPrQr#r�abc�abstractmethodr�r3rTr6rrr�r��s.��
�F�!"��5�G����
��
�*rr�c�,�\rSrSrSrSSjrSSjrSrg)	�	XDGViewer��z+63The freedesktop.org ``xdg-open`` command.64c��S=p4X44$)N�xdg-openr6)r'r1rrprzs     rr��XDGViewer.get_command_ex�s��)�)���"�"rc��[RRU5(d[e[R65"SU/5 g)r?r�r�r@rArBrCrcrdrEs   rr;�XDGViewer.show_file�s3���w�w�~�~�d�#�#�#�#����*�d�+�,�rr6Nr�rM�rNrOrPrQrRr�r;rTr6rrr�r��s���#�rr�c�@�\rSrSrSrSSSjjrS	SjrSrg)66�
DisplayViewer��zT67The ImageMagick ``display`` command.68This viewer supports the ``title`` parameter.69Nc�>�S=pEU(aUS[U53-
nXE4$)N�displayz -title r�r'r1rrrprzs      rr��DisplayViewer.get_command_ex�s-�� )�(�����%��,��0�0�G��"�"rc���[RRU5(d[eS/nUR	S5nU(aUSU/-
nURU5 [R"U5 g)r?r�rz-titler�r@rArBrC�getrrcrd�r'rAr�argsrs     rr;�DisplayViewer.show_file�sa���w�w�~�~�d�#�#�#�#��{�����G�$����X�u�%�%�D����D�������rr6r��r1rLrr*rrrIr�rMr�r6rrr�r��s6���.2�#��#� *�#�>A�#�	�#�
rr�c�,�\rSrSrSrSSjrSSjrSrg)	�GmDisplayVieweriz*The GraphicsMagick ``gm display`` command.c��SnSnXC4$)N�gmz70gm displayr6�r'r1rrzrps     rr��GmDisplayViewer.get_command_exs���71����"�"rc��[RRU5(d[e[R72"SSU/5 g)r?r�r�rr�rEs   rr;�GmDisplayViewer.show_files5���w�w�~�~�d�#�#�#�#����$�	�4�0�1�rr6Nr�rMr�r6rrr�r�s��4�#�73rr�c�,�\rSrSrSrSSjrSSjrSrg)	�	EogVieweriz'The GNOME Image Viewer ``eog`` command.c��SnSnXC4$)N�eogzeog -nr6r�s     rr��EogViewer.get_command_exs���74����"�"rc��[RRU5(d[e[R75"SSU/5 g)r?r�z-nrr�rEs   rr;�EogViewer.show_files5���w�w�~�~�d�#�#�#�#����%��t�,�-�rr6Nr�rMr�r6rrr�r�s��1�#�76rr�c�@�\rSrSrSrSSSjjrS	SjrSrg)77�XVVieweri'zL78The X Viewer ``xv`` command.79This viewer supports the ``title`` parameter.80Nc�>�S=pEU(aUS[U53-
nXE4$)N�xvz -name rr�s      rr��XVViewer.get_command_ex-s-��81 $�#������u���/�/�G��"�"rc���[RRU5(d[eS/nUR	S5nU(aUSU/-
nURU5 [R"U5 g)r?r�rz-namerr�r�s     rr;�XVViewer.show_file7sa���w�w�~�~�d�#�#�#�#��v�����G�$����W�e�$�$�D����D�������rr6r�r�rMr�r6rrr�r�'s6���.2�#��#� *�#�>A�#�	�#�
rr�)rhrr�r�r�r�r�c�"�\rSrSrSrSSjrSrg)�
IPythonVieweriTz!The viewer for IPython frontends.c��[U5 g)Nr)�ipython_displayr<s   rr&�IPythonViewer.show_imageWs
�����rr6NrG)rNrOrPrQrRr&rTr6rrr�r�Ts82��+�rr�)r��__main__�z.Syntax: python3 ImageShow.py imagefile [title])r)rztype[Viewer] | ViewerrrJrI�Noner�)rrHrr*rrrI�bool)(�83__future__rr�r@r{rcrx�shlexr�typingr�rrrrr
rV�platformrj�ABCr�r�r�r�r�r�r|r��IPython.displayr�r��ImportErrorrN�len�argv�print�exitrs�imr6rr�<module>r�s���#�84�	�
��85����
��#�,�7�7�z�F��6�<�<�7���]�� �� �F�<�<�8���Y��86*����&�87*��88��&�J��<�j��$�89��$�z��@�<�<�*�*�
�|�|�J������
�|�|�I������
�|�|�D�����!�
�|�|�E������
�|�|�D�������F���:�
�]���z��90�3�8�8�}�q��
�>�?����91�	���C�H�H�Q�K�	 �B�
�d�2�%�������%�&�92!�	 ���
�	��	��93!�	 �s�H�3H&�H#�"H#�&94H4
codekingpro/portable-devtools · Team Ai