Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2v�jVx��,�SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	J3r4JrJr SSK
JrJr SSKJrJr Sr\(aSSKJr \R,"\5rS	rS5rSrSSS
SSS.rS)SjrS*Sjr"SS\5r"SS\R5r "SS\RB5r""SS\ \RFS9r$"SS5r%S+S,Sjjr&S-S.Sjjr'S/S jr("S!S"5r)"S#S$5r*"S%S&\*5r+"S'S(\*5r,g)0�)�annotationsN)�IO�Any�6NamedTuple�cast�)�ExifTags�Image)�
DeferredError�is_pathF)�StrOrBytesPathiizimage buffer overrun errorzdecoding errorz
unknown errorzbad configurationzout of memory error)��������������������i����c���[RRU5nU(dU(aSOSSU3nUSU(aSOSS3-
n[
U5$![a [RU5nNUf=f)N�encoder�decoderz error z when �writing�readingz image file)r7�core�getcodecstatus�AttributeError�ERRORS�get�OSError)�errorr�msgs   �SD:\code\apps\devtools\python\user_packages\Python313\site-packages\PIL/ImageFile.py�_get_oserrorr Vsv�� ��j�j�'�'��.���%��9�5�W�U�G�D���V��I�i�8��D�D�C��3�<���� ��j�j���� �s�A�A7�6A7�_Tilec��US$)N��)�ts r�	_tilesortr&as���Q�4�K�c�F�\rSrSr%S\S'S\S'SrS\S'S	rS8\S'Srg	)
r!�f�str�9codec_name� tuple[int, int, int, int] | None�extentsr�int�offsetNztuple[Any, ...] | str | None�argsr$)�__name__�10__module__�__qualname__�__firstlineno__�__annotations__r/r0�__static_attributes__r$r'rr!r!fs!���O�
-�-��F�C�O�)-�D�11&�-r'c��^�\rSrSrSrSSU4SjjjrSSjrSSjrSSjrSSjr	SU4Sjjr12SS	jrSS13jrSU4Sjjr
SU4SjjrSS
jrSSjrSSjrSSjrSSjrSrU=r$)�	ImageFile�rz*Base class for image file format handlers.c�>�[TU]5 SUlSUl/UlSUlSUl[UlU U [U5(a4[US5Ul[R"U5UlSUlO/[!["[$U5UlUbUOSUlSUlUR'5 [)U[*5(a(UR-5=n(aURU5 UR<(a&UR>SS::dUR>SS::a
Sn[;U5eg![.[0[2[4[6R84an[;U5UeSnAff=f![@a- UR(aURRC5 ef=f)	Nrrr$�rbT�Fznot identified by this driver)"�super�__init__�14_min_frame�custom_mimetype�tile�readonly�
decoderconfig�MAXBLOCK�decodermaxblockr�open�fp�os�fspath�filename�
_exclusive_fprr�bytes�_open�15isinstance�
StubImageFile�_load�16IndexError�	TypeError�KeyError�EOFError�structr�SyntaxError�mode�size�
BaseException�close)�selfrGrJ�loader�vr�	__class__s      �rr>�ImageFile.__init__usu���	�������+/���!#��	�*���
�.0���'������2�;�;��2�t�n�D�G��I�I�b�M�D�M�!%�D���2�e�9�b�)�D�G�(0�(<�H�"�D�M�!&�D��	�

,��17�18���d�M�2�2�!%����-�v�-����D�)��9�9��	�	�!��� 1�T�Y�Y�q�\�Q�5F�5��!�#�&�&�6G����������
,�"�!�n�!�+��
,���	��!�!����
�
���		�s,�8A
E19�AF�20)F�3E?�?F�F�7F>c��g�Nr$�r[s rrM�ImageFile._open����r'c��U$rar$rbs r�	__enter__�ImageFile.__enter__�����r'c�X�[USS5(al[UR[5(dMURUR:waURR5 [[
S55UlUR(aURR5 gg)N�_fpFzOperation on closed image)�getattrrNrjrrGrZ�21ValueErrorrbs r�	_close_fp�ImageFile._close_fp�sj���4���&�&�z�$�(�(�M�/R�/R��x�x�4�7�7�"������ �$�Z�0K�%L�M�D�H��7�7��G�G�M�M�O�r'c�V�[USS5(aUR5 SUlg)NrKF)rkrmrG�r[r0s  r�__exit__�ImageFile.__exit__�s"���4��%�0�0��N�N����r'c�>�UR5 SUl[22TU]5 g![a n[R	SU5 SnAN4SnAff=f)ae23Closes the file pointer, if possible.24 25This operation will destroy the image core and release its memory.26The image data will be unusable afterward.27 28This function is required to close images that have multiple frames or29have not had their file read and closed by the30:py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for31more information.32NzError closing: %s)rmrG�	Exception�logger�debugr=rZ)r[rr^s  �rrZ�ImageFile.close�sH���	3��N�N���D�G�	��
����	3��L�L�,�c�2�2��	3�s�)�33A�A�Ac���/nUR5n/n[RRU;a_U[RRnU(a;[	U[345(dU4nUVs/sHnUR
U5U4PM nnUR[RR5nU(acUR[RR5(a5URceURXbRR45 SnUGH�up�URceURR!5n35UcU36nURnUb�UR[RR5nUb�U[#USS5-
nURR%U5 UR[RR&5n
[	U
[(5(deURR+U
5n[,R."U5n[0R2"U5nSSKJn Wc4[	UUR85(aU	/UlUR=S5 UR?5 URU5 SSS5 GM� Ub*URceURR%U5 U$s snf!,(df   GM�=f)N�_exif_offsetrr)�TiffImagePlugin) �getexifr	�Base�SubIFDsrN�tuple�
_get_ifd_dict�get_ifd�IFD�IFD1r�JpegIFOffset�_info�append�nextrG�tellrk�seek�JpegIFByteCountr.�read�io�BytesIOr37rFr<rz�
TiffImageFile�38_frame_pos�_seek�load)r[�child_images�exif�ifds�subifd_offsets�
subifd_offset�ifd1r/�ifd�39ifd_offset�current_offsetrG�thumbnail_offset�length�data�imrzs                 r�get_child_images�ImageFile.get_child_images�sW�����|�|�~�����=�=� � �D�(�!�(�-�-�"7�"7�8�N��!�.�%�8�8�&4�%6�N�*8��)7�
��'�'�
�6�
�F�)7����|�|�H�L�L�-�-�.���D�H�H�X�]�]�7�7�8�8��:�:�)�)�)��K�K��z�z���/�0���#�O�C��7�7�&�&�&�!�W�W�\�\�^�N��~�'�����B���#&�7�7�8�=�=�+E�+E�#F� �#�/�$���n�a�(H�H�$��G�G�L�L�!1�2� �W�W�X�]�]�%B�%B�C�F�%�f�c�2�2�2�2��7�7�<�<��/�D����D�)�B����B��2�-�#�+�40���5�5�1�1�&0�L�B�M��H�H�Q�K����	��#�#�B�'� ��% $�:���7�7�&�&�&��G�G�L�L�� ����U�8 ��s�3K%�41AK*�*42K:	c���UR(aUR$URb7[RR	URR55$gra)r@�formatr43�MIMEr�upperrbs r�get_format_mimetype�ImageFile.get_format_mimetype44sD������'�'�'��;�;�"��:�:�>�>�$�+�+�"3�"3�"5�6�6�r'c�<>�[TU]5UR/-$ra)r=�__getstate__rJ)r[r^s �rr��ImageFile.__getstate__s����w�#�%�����7�7r'c�d>�/Ul[U5S:�a45USUl[TU]U5 g)N�)rA�lenrJr=�__setstate__)r[�stater^s  �rr��ImageFile.__setstate__s-�����	��u�:��>�!�!�H�D�M�
���U�#r'c��UR(a+UR(aURR5 SUlg)zCheck file integrityN)rKrGrZrbs r�verify�ImageFile.verifys'��46���$�'�'��G�G�M�M�O���r'c���UR(dURc
Sn[U5e[RR	U5nUR(dU$SUlUR=(a [UR5S:HnURceSn[US5(aURnSnOURRn[US5(aURnSnOURRnU(Ga�URSupxp�[U47[5(aU48SS4n49US:XGaU[U50[ 5(Ga?[U515S	:�Ga/U52SUR":XGaU53S[R$;GaU	S:a
S54n['U5eSSKn[+UR5nUR)UR-5SUR.S9UlSSS5 X�R0SU55S--UR56R15:�a
Sn[U5e[R2R5UR57UR0XyU585UlSnUR8(aSUR8lURA5 S
n
UR59(Gd�URRC[DS9 [GUSS5n[HRJ"URS5VVs/sHunn[MU5SPM snnUl[OUR5GH[unupxp�U"U	5 [RP"UR"XzURR5nURUUR6U5 URV(a0URYUR5 UR[S5Sn
O�UnUR\nUS-[UR5:a'URUS-R^nUU	:�aUU	-60nU"U5nU(d&[f(aOAS[U5S3n[U5eUU-nUR[U5unn
US:aOUUSnM�URi5 GM^ /UlX@l5URm5 URn(a+URp(aURRs5 SUlUR61(d(dU
S:a62[uU
SS9e[RR	U5$!,(df   GNe=f![<[[>4a SUlGN�f=fs snnf![`[bRd4a%n[f(aSnAGM'Sn[U5UeSnAff=f!URi5 f=f)z"Load image data based on tile listNzcannot load this imagerr�	load_readF�	load_seek�raw�zTile offset cannot be negative)�accesszbuffer is not large enoughr��key�tile_prefixr'c��USUSUS4$)Nrrr�r$)rAs r�<lambda>� ImageFile.load.<locals>.<lambda>rs��T�!�W�d�1�g�t�A�w�,Gr'rzimage file is truncatedzimage file is truncated (z bytes not processed)�r);rA�_imrr63r��maprJr�rG�hasattrr�r�r�r�rNr*r~rW�	_MAPMODESrl�mmaprF�fileno�ACCESS_READrXr�64map_bufferr��palette�dirtyr�ImportError�load_prepare�sortr&rk�	itertools�groupby�list�	enumerate�_getdecoderrC�setimage�pulls_fd�setfd�decoderEr/rQrUr�LOAD_TRUNCATED_IMAGES�cleanuprB�load_endrK�!_close_exclusive_fp_after_loadingrZr )r[r�pixel�use_mmaprBr�r��decoder_namer-r/r0r�rG�err_code�prefix�_�tiles�ir�b�65read_bytes�next_offset�s�e�ns                         rr��ImageFile.load#s����y�y�T�X�X�-�*�C��#�,����� � ��&���y�y��L�%)����=�=�8�S����^�q�%8���w�w�"�"�"����4��%�%��>�>�D��H��7�7�<�<�D��4��%�%��>�>�D��H��7�7�<�<�D��26�)�)�A�,�/�L�6��$��$�$��a��|����%��t�U�+�+���I��N���G�t�y�y�(���G�u���.��A�:�:�C�$�S�/�)�$���d�m�m�,��#'�9�9�R�Y�Y�[�!�D�DT�DT�9�#U���-��	�	�!��t�A�w� 6�6�������H�:��%�c�l�*�#�j�j�3�3����$�)�)�\�4��D�G� !�H��|�|�-.����*�	
�������x�x�x��I�I�N�N�y�N�)��T�=�#�6�F�66!*� 1� 1��I�I�G�!��!�H�A�u��U��B��!��D�I�=F�d�i�i�<P�8��8�L�6��V���+�+��I�I�|�4�3E�3E���(&��$�$�T�W�W�g�6��'�'��
�
�d�g�g�.�#*�>�>�#�#6�q�#9��"��"�)-�)=�)=�J� �1�u�s�4�9�9�~�5�.2�i�i��A��.>�.E�.E��#.��#7�1<�v�1E�J�>�$(��$4��$%�#8�#8�$)�),�,/��F�8�3H�)J�%(�+2�#�,�$6� !�A��A�*1�.�.��*;�K�A�x� �1�u� %� !�!�"��A�=#�B�O�O�%�[=Q�^��	� �
��
�
�����$�"H�"H��G�G�M�M�O�����x�x� 5� 5�(�Q�,��x��7�7��{�{����%�%�y-�,��'���=�$�#�D�H�$����4%/����#=�>�#8�#8�$)�*C�C�*1�#�,�A�$=��
>��2�O�O�%�so�.U&�/U�6B'U&�V	�B/W�8V�AW�67U#�U&�&V�V�W�)W	�4W�;W	�	W�W�W#c���URc9[RRURUR685UlURS:Xa [RRU5 gg)N�P)r�r69r�newrWrXr�r�rbs rr��ImageFile.load_prepare�sM���8�8���j�j�n�n�T�Y�Y��	�	�:�D�G��9�9����K�K���T�"�r'c��grar$rbs rr��ImageFile.load_end����r'c���XR:d;[US5(a
URb*U[US5UR-:�a
Sn[	U5eUR5U:g$)N�	_n_frames�n_framesz attempt to seek outside sequence)r?r�r�rkrTr�)r[�framers   r�_seek_check�ImageFile._seek_check�s^���O�O�#��T�;�/�/�D�N�N�4J��W�T�:�6����H�H�5�C��3�-���y�y�{�e�#�#r')rKrjr?r@rCrErJrGr�r�rBrAra)rGzStrOrBytesPath | IO[bytes]rJzstr | bytes | None�return�None�r�r�)r�r8�r0�objectr�r�)r�zlist[ImageFile])r��70str | None)r��	list[Any])r�r�r�r��r�zImage.core.PixelAccess | None)r�r.r��bool)r1r2r3r4�__doc__r>rMrfrmrqrZr�r�r�r�r�r�r�r�r�r6�
__classcell__)r^s@rr8r8rs~���4�NR�6�,�6�8J�6�	
�6�6�p
����71�(3�j�8�$��N&�`#�
�
$�
$r'r8c�F�\rSrSrSSjr\RSSj5rSrg)�StubHandleri�c��grar$�r[r�s  rrF�StubHandler.open�rdr'c��grar$rs  rr��StubHandler.load�r�r'r$N)r�rOr�r�)r�rOr��Image.Image)	r1r2r3r4rF�abc�abstractmethodr�r6r$r'rrr�s!��
�	���
��
r'rc�r�\rSrSrSr\RSSj5rS	Sjr\RS72Sj5r	Sr73g)rOi�z�74Base class for stub image loaders.75 76A stub loader is an image loader that can identify files of a77certain format, but relies on external code to load the file.78c��grar$rbs rrM�StubImageFile._open�r�r'c���UR5nUcSURS3n[U5eURU5nUceURUlUR79UlUR5$)Nzcannot find loader for this z file)rPr�rr�r^�__dict__)r[r\r�images    rr��StubImageFile.load�sj��������>�0����
�U�C�C��#�,�����D�!��� � � ����������
��z�z�|�r'c��g)z (Hook) Find actual image loader.Nr$rbs rrP�StubImageFile._load�s��	
r')r^rNr�r�)r�zStubHandler | None)r1r2r3r4r�rr	rMr�rPr6r$r'rrOrO�s@���	���
��
�80�	���
��
r'rO)�	metaclassc��\rSrSr%SrSrSrS\S'SrS\S'Sr	S\S	'S81r82S83rSSjrSSjr
SS
jrSSjrSSjrSrg)�Parseri�z^84Incremental image parser.  This class implements the standard85feed/close consumer interface.86NzImage.Image | Nonerzbytes | Noner�z,Image.core.ImagingDecoder | PyDecoder | Nonerrc�,�URbS5eg)z�87(Consumer) Reset the parser.  Note that you can only call this88method immediately after you've created a parser; parser89instances cannot be reused.90Nzcannot reuse parsers)r�rbs r�reset�Parser.resets���y�y� �8�"8�8� r'c�~�UR(agURcXlOURU-UlUR(a�URS:�as[	[UR5UR5nURUSUlURU-91UlURS:�dUR(dgURR
UR5up4US:a&SUlSUlUS:aSUl[USS9egURUSUlgUR(ag[R"UR5n[R"U5nSSS5 [WS5=(d [US5nU(d�[UR5S:Xa�UR5 URSup�p�/Ul[R "UR"X�UR$5UlURR'UR(U5 X�lUR[UR5::a%URURSUlSUlX`lg!,(df   GN#=f![*a gf=f)z�92(Consumer) Feed data to the parser.93 94:param data: A string buffer.95:exception OSError: If the parser failed to parse the image file.96NrrFr�r�r�)�finishedr�rr/�minr�r�rr r�r�r97rFr�rAr�r�rWrCr�r�r)r[r��skipr�r�rGr��flag�d�o�as           r�feed�Parser.feeds���=�=���9�9���I��	�	�D�(�D�I��<�<��{�{�Q���3�t�y�y�>�4�;�;�7�� �I�I�d�e�,��	�"�k�k�D�0����;�;��?�$�)�)���<�<�&�&�t�y�y�1�D�A��1�u� ��	� !��
��q�5�!%�D�J�&�q�%�8�8���	�	�!�"�
�D�I�
�Z�Z�
�
 ��Z�Z��	�	�*�b����B��B�+�98�r�;�/�K�7�2�{�3K����B�G�G��� 1��O�O�%�!#�����J�A�!� �B�G�#(�#4�#4�R�W�W�a�B�DT�DT�#U�D�L��L�L�)�)�"�%�%��3�#$�K��{�{�c�$�)�)�n�4�$(�I�I�d�k�k�m�$<��	�&'����99�)+�*���
��
�s*�100 J/�*J�J/�101J,�'J/�/102J<�;J<c��U$rar$rbs rrf�Parser.__enter__\rhr'c�$�UR5 gra)rZrps  rrq�Parser.__exit___s���103�104�r'c�b�UR(a=URS5 S=UlUlUR(d
Sn[	U5eUR105(d
Sn[	U5eUR(al[R"UR5n[R"U5UlUR106R5 SSS5 UR107$UR108$!UR109R5 f=f!,(df   UR110$=f)z�111(Consumer) Close the stream.112 113:returns: An image object.114:exception OSError: If the parser failed to parse the image file either115                    because it cannot be identified or cannot be116                    decoded.117r'Nzimage was incompletezcannot parse this image)rr!r�rrrr�r�r118rFr�)r[rrGs   rrZ�Parser.closebs����<�<��I�I�c�N�'+�+�D�I����=�=�,���c�l�"��z�z�+�C��#�,���9�9����D�I�I�&�"�&�!&���B��D�J��J�J�O�O�%�	'�119�z�z��t�z�z����J�J�O�O�%��	'�&�120�z�z��s$�D� C6�;D�6D�D�121D.)r�rrrr/r�)r�rLr�r�)r�rr�)r�r)r1r2r3r4r��incrementalrr5r�rr/rrr!rfrqrZr6r$r'rrr�sS���122�K� $�E��$��D�,��<@�G�
9�@�
�F��H�9�G �R��r'rc	���UR5 [US5(dSUlUR[S9 [[X0RSS-5nUR5nUR5 [XX#U5 [US5(aUR5 gg![[R4an[XX#SU5 SnANPSnAff=f)z�Helper to save image based on tile list123 124:param im: Image object.125:param fp: File object.126:param tile: Tile list.127:param bufsize: Optional buffer size128�
encoderconfigr$r�r�N�flush)r�r�r+r�r&�maxrDrXr�r-�_encode_tilerr��UnsupportedOperation)r�rGrA�bufsize�fh�excs      r�_saver4�s����G�G�I��2��'�'�����I�I�)�I��129�(�G�W�W�Q�Z�!�^�4�G�7�
�Y�Y�[��130���131��R�T�B�/��r�7���132���133���
�B�3�3�4�7��R�T�D�#�6�6��7�s�-B-�-C�C�Cc�X�UGHupgp�US:�aURU5 [R"URXiUR5n134U135RURU5 U136R(a%U137RU5 U138R5SnOOU(a2U139RU5SSup�URU5 U(aOM1UceU140RXC5nUS:a[USS9UeU141R5 GM g!U142R5 f=f)NrrTr�)r�r143�_getencoderrWr+r�r��	pushes_fdr��encode_to_pyfd�encode�write�encode_to_filer r�)
r�rGrAr1r2r3�encoder_namer-r/r0r�errcoder�s
             rr/r/�s��04�+��v��A�:��G�G�F�O��#�#�B�G�G�\��AQ�AQ�R��	����R�U�U�G�,�� � ��
�
�b�!�!�0�0�2�1�5����(/���w�(?���(C�
�������"�!�	��>�)�>�%�4�4�R�A�G���{�"�7�D�9�s�B��
�O�O��104��0
�O�O��s
�B2D�D)c��US::agU[::a/URU5n[U5U:a
Sn[U5eU$/nUnUS:�aNUR[	U[55nU(dO'URU5 U[U5-nUS:�aMN[
SU55U:a
Sn[U5eSRU5$)a�144Reads large blocks in a safe way.  Unlike fp.read(n), this function145doesn't trust the user.  If the requested size is larger than146SAFEBLOCK, the file is read block by block.147 148:param fp: File handle.  Must implement a <b>read</b> method.149:param size: Number of bytes to read.150:returns: A string containing <i>size</i> bytes of data.151 152Raises an OSError if the file is truncated and the read cannot be completed153 154rr'zTruncated File Readc3�8# �UHn[U5v� M g7fra)r�)�.0�blocks  r�	<genexpr>�_safe_read.<locals>.<genexpr>�s���155*�6�%�3�u�:�:�6�s�)�	SAFEBLOCKr�r�rrr��sum�join)rGrXr�r�blocks�remaining_sizerAs       r�156_safe_readrI�s����q�y���y���w�w�t�}���t�9�t��'�C��#�,�����F��N�157�1�158�����N�I�6�7�����
�
�e���#�e�*�$���1�159��160*�6�161*�*�T�1�#���c�l���8�8�F��r'c�(�\rSrSrSSjrSSjrSrg)�PyCodecStatei�c�<�SUlSUlSUlSUlg)Nr)�xsize�ysize�xoff�yoffrbs rr>�PyCodecState.__init__�s����162���163���	���	r'c��URURURUR-URUR-4$ra)rOrPrMrNrbs rr-�PyCodecState.extents�s3���y�y�$�)�)�T�Y�Y����%;�T�Y�Y����=S�S�Sr')rOrMrPrNNr�)r�ztuple[int, int, int, int])r1r2r3r4r>r-r6r$r'rrKrK�s
���Tr'rKc�b�\rSrSr%S\S'SSjrSSjrS
SjrSSjrSSS	jjr	S164r165g)�PyCodeci�zIO[bytes] | None�fdc�l�SUl[5UlSUlXlURU5 gra)r�rKr�rVrW�init)r[rWr0s   rr>�PyCodec.__init__�s)��15���!�^��166�����	��	�	�$�r'c��Xlg)zw167Override to perform codec specific initialization168 169:param args: Tuple of arg items from the tile entry170:returns: None171N)r0rps  rrX�PyCodec.init�s	���	r'c��g)z<172Override to perform codec specific cleanup173 174:returns: None175Nr$rbs rr��PyCodec.cleanups��	
r'c��Xlg)zo176Called from ImageFile to set the Python file-like object177 178:param fd: A Python file-like object179:returns: None180N)rV)r[rVs  rr��
PyCodec.setfds	���r'Nc�H�XlU(a�Uup4pVUS:d>US:d8XPRRS:�dX`RRS:�a
Sn[U5eX0RlX@RlXS-181URlXd-182URlO7URRuURlURlURRS::dURRS::a
Sn[U5eg)z�183Called from ImageFile to set the core output image for the codec184 185:param im: A core image object186:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle187    for this tile188:returns: None189rrz Tile cannot extend outside imagezSize must be positiveN)r�rXrlr�rOrPrMrN)r[r�r-�x0�y0�x1�y1rs        rr��PyCodec.setimages������$�N�B�B��A�v��a��2�����Q��#7�2�����Q��;O�8�� ��o�%� �J�J�O� �J�J�O�!�w�D�J�J��!�w�D�J�J��15�����.�D�J�J��d�j�j�.��:�:���q� �D�J�J�$4�$4��$9�)�C��S�/�!�%:r')r0rVr�rWr�)rWr*r0rr�r�)r0�tuple[Any, ...]r�r�r�)rV�	IO[bytes]r�r�ra)r�zImage.core.ImagingCorer-r,r�r�)r1r2r3r4r5r>rXr�r�r�r6r$r'rrUrU�sG������
��59�!"�"�!"�2�!"�190�	!"�!"r'rUc�X�\rSrSrSrSr\S	Sj5rS191SjrSSSjjr	Sr192g)
�	PyDecoderi9z�193Python implementation of a format decoder. Override this class and194add the decoding logic in the :meth:`decode` method.195 196See :ref:`Writing Your Own File Codec in Python<file-codecs-py>`197Fc��UR$ra)�	_pulls_fdrbs rr��PyDecoder.pulls_fdCs���~�~�r'c��Sn[U5e)a
198Override to perform the decoding process.199 200:param buffer: A bytes object with the data to be decoded.201:returns: A tuple of ``(bytes consumed, errcode)``.202    If finished with decoding return -1 for the bytes consumed.203    Err codes are from :data:`.ImageFile.ERRORS`.204zunavailable in base decoder��NotImplementedError)r[�bufferrs   rr��PyDecoder.decodeG���,��!�#�&�&r'Nr$c�n�U(dURn[R"URSX#5nURceUR	URUR205R
55 URU5nUSS:�a
Sn[U5eUSS:wa
Sn[U5eg)a206Convenience method to set the internal image from a stream of raw data207 208:param data: Bytes to be set209:param rawmode: The rawmode to be used for the decoder.210    If not specified, it will default to the mode of the image211:param extra: Extra arguments for the decoder.212:returns: None213r�Nrznot enough image datarzcannot decode image data)	rWr214r�r�r�r�r-r�rl)r[r��rawmode�extrarr�rs       r�215set_as_raw�PyDecoder.set_as_rawSs�����i�i�G����d�i�i���?���w�w�"�"�"�	�216�217�4�7�7�D�J�J�.�.�0�1�
�H�H�T�N���Q�4�1�9�)�C��S�/�!��Q�4�1�9�,�C��S�/�!�r'�r�r�)rpz$bytes | Image.SupportsArrayInterfacer��tuple[int, int])Nr$)r�rLrtr�rurfr�r�)r1r2r3r4r�rk�propertyr�r�rvr6r$r'rriri9sV����I�
����218'�QS�"��"�$.�"�>M�"�	
�"�"r'ric�N�\rSrSrSrSr\S219Sj5rSSjrSSjr	S
Sjr220Srg	)�	PyEncoderioz�221Python implementation of a format encoder. Override this class and222add the decoding logic in the :meth:`encode` method.223 224See :ref:`Writing Your Own File Codec in Python<file-codecs-py>`225Fc��UR$ra)�226_pushes_fdrbs rr7�PyEncoder.pushes_fdys�����r'c��Sn[U5e)z�227Override to perform the encoding process.228 229:param bufsize: Buffer size.230:returns: A tuple of ``(bytes encoded, errcode, bytes)``.231    If finished with encoding return 1 for the error code.232    Err codes are from :data:`.ImageFile.ERRORS`.233zunavailable in base encoderrn)r[r1rs   rr9�PyEncoder.encode}rrr'c��UR(dgURS5upnU(a*URceURRU5 X4$)z�234If ``pushes_fd`` is ``True``, then this method will be used,235and ``encode()`` will only be called once.236 237:returns: A tuple of ``(bytes consumed, errcode)``.238    Err codes are from :data:`.ImageFile.ERRORS`.239)rrr)r7r9rVr:)r[�bytes_consumedr=r�s    rr8�PyEncoder.encode_to_pyfd�sL���~�~��(,���A��%�����7�7�&�&�&��G�G�M�M�$���&�&r'c��SnUS:Xa;URU5upCnUS:�a[R"XUS5 US:XaM;U$)z�240:param fh: File handle.241:param bufsize: Buffer size.242 243:returns: If finished successfully, return 0.244    Otherwise, return an error code. Err codes are from245    :data:`.ImageFile.ERRORS`.246rN)r9rHr:)r[r2r1r=�status�bufs      rr;�PyEncoder.encode_to_file�sL������l�#'�;�;�w�#7� �F�S���z�������\�*���l��r'r$Nrx)r1r.r�ztuple[int, int, bytes])r�ry)r2r.r1r.r�r.)r1r2r3r4r�r~rzr7r9r8r;r6r$r'rr|r|os/����J�
����247'�'� r'r|)rr.rr�r�r)r%r!r�r.)r)248r�rrGrgrA�list[_Tile]r1r.r�r�ra)r�rrGrgrAr�r1r.r2z249int | Noner3zBaseException | Noner�r�)rGrgrXr.r�rL)-�250__future__rrr�r��loggingrHrU�typingrrrrr<r	r251�_utilrr�
TYPE_CHECKING�_typingr
�	getLoggerr1rurDrDr�rr r&r!r8�ABCr�ABCMetarOrr4r/rIrKrUrir|r$r'r�<module>r�s]��:#�252�	���	�
�,�,��)��
��'�	�	�	�8�	$�����
�	���N�	%�����253�����254.�J�.�b$����b$�J
�#�'�'�
�
�I����
�<@�@�L�D!%�
 �� �� �� ��	 �255	� �256�
 �257� �F �FT�T�E"�E"�P3"��3"�l8��8r'
codekingpro/portable-devtools · Team Ai