%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/PIL/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/PIL/__pycache__/Jpeg2KImagePlugin.cpython-312.pyc

�

��e5-���ddlmZddlZddlZddlZddlmZmZmZGd�d�Z	d�Z
d�Zd	�ZGd
�dej�Z
d�Zd
�Zej e
j"e
e�ej$e
j"e�ej&e
j"gd��ej(e
j"d�y)�)�annotationsN�)�Image�	ImageFile�_binaryc�<�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)�	BoxReaderz}
    A small helper class to read fields stored in JPEG2000 header boxes
    and to easily step into and read sub-boxes.
    c�B�||_|dk\|_||_d|_y)Nr���)�fp�
has_length�length�remaining_in_box)�selfrrs   �7/usr/lib/python3/dist-packages/PIL/Jpeg2KImagePlugin.py�__init__zBoxReader.__init__s#����� �A�+������ "���c��|jr+|jj�|z|jkDry|jdk\r||jkSy)NFrT)r
r�tellrr)r�	num_bytess  r�	_can_readzBoxReader._can_read%sH���?�?�t�w�w�|�|�~�	�9�D�K�K�G��� � �A�%��� 5� 5�5�5�rc��|j|�s
d}t|��|jj|�}t	|�|krd|�dt	|��d�}t|��|jdkDr|xj|zc_|S)NzNot enough data in headerzExpected to read z bytes but only got �.r)r�SyntaxErrorr�read�len�OSErrorr)rr�msg�datas    r�_read_byteszBoxReader._read_bytes/s����~�~�i�(�-�C��c�"�"��w�w�|�|�I�&���t�9�y� �%�i�[�0D�S��Y�K�q�Q�C��#�,��� � �1�$��!�!�Y�.�!��rc�z�tj|�}|j|�}tj||�S�N)�struct�calcsizer �unpack)r�field_format�sizers    r�read_fieldszBoxReader.read_fields=s1�����|�,������%���}�}�\�4�0�0rc�z�|j}|j|�}ttj|�|�Sr")rr r	�io�BytesIO)rr'rs   r�
read_boxeszBoxReader.read_boxesBs3���$�$������%������D�)�4�0�0rc��|jr4|jj�|jz|jkSy)NT)r
rrrr)rs r�has_next_boxzBoxReader.has_next_boxGs0���?�?��7�7�<�<�>�D�$9�$9�9�D�K�K�G�G�rc�^�|jdkDr4|jj|jtj�d|_|jd�\}}|dk(r|jd�d}d}nd}||ks|j
||z
�s
d}t|��||z
|_|S)	Nrrz>I4srz>Q��zInvalid header length)rr�seek�os�SEEK_CURr(rr)r�lbox�tbox�hlenrs     r�
next_box_typezBoxReader.next_box_typeMs���� � �1�$��G�G�L�L��.�.����<� "����%�%�f�-�
��d��1�9��#�#�D�)�!�,�D��D��D��$�;�d�n�n�T�D�[�9�)�C��c�"�"� $�t�����rN)r)�__name__�
__module__�__qualname__�__doc__rrr r(r,r.r8�rrr	r	s*���
#���1�
1�
�rr	c���|jd�}tj|�}||j|dz
�z}tjd|�\}}}}}}}	}	}	}	}
dg|
z}dg|
z}dg|
z}
t|
�D],}tjd|dd|zz�\||<||<|
|<�.||z
||z
f}|
dk(r|
dd	zd
kDrd}||fSd}||fS|
dk(rd
}||fS|
dk(rd}||fS|
dk(rd}||fSd}||fS)z�Parse the JPEG 2000 codestream to extract the size and component
    count from the SIZ marker segment, returning a PIL (size, mode) tuple.�z>HHIIIIIIIIHNz>BBB�$�rr�r1�I;16�L�LA�RGB��RGBA)rr�i16ber#�unpack_from�range)r�hdr�lsiz�siz�rsiz�xsiz�ysiz�xosiz�yosiz�_�csiz�ssiz�xrsiz�yrsiz�ir'�modes                 r�_parse_codestreamr[csw��
�'�'�!�*�C��=�=���D�

�����q��!�
!�C�=C�=O�=O���>�:�D�$��d�E�5�!�Q��1�d�
�6�D�=�D�
�F�T�M�E�
�F�T�M�E�
�4�[�R��&,�&8�&8���b�1�q�5�j�&Q�#��Q���q��5��8�R�
�5�L�$��,�'�D��q�y��!�H�t�O�q� ��D���:���D���:��
�������:��
�������:��
�������:������:�rc�0�|dk7rd|zd|zzd|zzSy)z�Convert JPEG2000's (numerator, denominator, exponent-base-10) resolution,
    calculated as (num / denom) * 10^exp and stored in dots per meter,
    to floating-point dots per inch.r��
i'Nr=)�num�denom�exps   r�_res_to_dpirb�s,��
��z��c�	�R��W�%�%�%�-�8�8�rc�8�t|�}d}d}|j�rU|j�}|dk(r|j�}n/|dk(r|j	d�ddk(rd}|j�r�Ud}d}d}d}d}	|j�r�|j�}|dk(rJ|j	d	�\}
}}}||
f}|d
k(r|dzdkDrd
}n�|d
k(rd}n�|dk(rd}n�|dk(rd}n�|dk(r�d}n�|dk(r�|j�}|j�ra|j�}
|
dk(r;|j	d�\}}}}}}t|||�}t|||�}|�|�||f}	n|j�r�a|j�r��|�|�
d}t
|��||||	fS)z�Parse the JP2 header box to extract size, component count,
    color space information, and optionally DPI information,
    returning a (size, mode, mimetype, dpi) tuple.Nsjp2hsftypz>4srsjpx z	image/jpxsihdrz>IIHBrrBr1rCrDr?rErArFrGrHsres srescz>HHHHBBzMalformed JP2 header)r	r.r8r,r(rbr)r�reader�header�mimetyper6r'rZ�bpc�nc�dpi�height�width�res�tres�vrcn�vrcd�hrcn�hrcd�vrce�hrce�hres�vresrs                       r�_parse_jp2_headerrv�s����r�]�F�
�F��H�
�
�
�
��#�#�%���7�?��&�&�(�F��
�W�_��!�!�%�(��+�w�6�&���
�
�
��D��D�
�C�	
�B�
�C�
�
�
�
��#�#�%���7�?�%+�%7�%7��%@�"�F�E�2�s��6�?�D��Q�w�C�$�J�!�+����q�����q�����q�����q����
�W�_��#�#�%�C��"�"�$��(�(�*���7�?�9<����9S�6�D�$��d�D�$�&�t�T�4�8�D�&�t�T�4�8�D��'�D�,<�#�T�l����"�"�$�%�
�
�
�8�|�t�|�$���#�����x��$�$rc�f��eZdZdZdZd�Zd�Ze�fd��Zejd��Zd�Z
�xZS)�Jpeg2KImageFile�JPEG2000zJPEG 2000 (ISO 15444)c��|jjd�}|dk(r*d|_t|j�\|_|_n�||jjd�z}|dk(r~d|_t
|j�}|\|_|_|_}|�||jd<|jjd�jd	�r|j�n
d
}t|��|j�|j�
d}t|��d|_d|_d
}d
}	|jj!�}t#j$|�j&}dd|jzd|j|j|j||ffg|_y#t($r�d
}	|jj+�}|jj-dt.j0�|jj+�}|jj-|�n#t($rd
}YnwxYwY��wxYw)NrG��O�Q�j2kr1�jP  
�
�jp2ri�sjp2c�O�Qznot a JPEG 2000 filezunable to determine size/moderr�jpeg2k�rr)rr�codecr[�_size�_moderv�custom_mimetype�info�endswith�_parse_commentrr'rZ�_reduce�layers�filenor3�fstat�st_size�	Exceptionrr2r*�SEEK_END�tile)r�sigrerir�fdr�poss        r�_openzJpeg2KImageFile._open�s����g�g�l�l�1�o���%�%��D�J�%6�t�w�w�%?�"�D�J��
�������Q��'�C��=�=�"��
�*�4�7�7�3��DJ�A��
�D�J��(<�c��?�'*�D�I�I�e�$��7�7�<�<��#�,�,�-D�E��'�'�)�,��!�#�&�&��9�9���	�	� 1�1�C��c�"�"�������
����	������!�B��X�X�b�\�)�)�F������"�����T�\�\�4�;�;��F�C�	
�
��	���	��B�
��g�g�l�l�n�������Q����,�������������S�!���
���
��	�s7�19F'�'I�3A9H-�,I�-H;�8I�:H;�;I�Ic�2�|jjd�}tj|�}|jj	|dz
t
j�	|jjd�}|sy|d}|dvry|jjd�}tj|�}|dk(r/|jj|dz
�dd|jd<y|jj	|dz
t
j���)Nr?r)����d�comment)rrrrIr2r3r4r�)rrLr�marker�typs     rr�zJpeg2KImageFile._parse_comments����g�g�l�l�1�o�����s�#�������V�a�Z����-���W�W�\�\�!�_�F�����)�C��l�"���'�'�,�,�q�/�C��]�]�3�'�F��d�{�'+�w�w�|�|�F�Q�J�'?���'C��	�	�)�$�������V�a�Z����5�rc�4��|jxs
t�|�Sr")r��super�reduce)r�	__class__s �rr�zJpeg2KImageFile.reduces���
�|�|�-�u�w�~�-rc��||_yr")r�)r�values  rr�zJpeg2KImageFile.reduce"s	����rc���|jr�|jr�d|jz}|dz	}t|jd|z|z�t|jd|z|z�f|_|jd}|dd|j|j
|dd|ddf}|dd|jz|d|fg|_tjj|�S)NrrrArGr�r?)r�r��intr'r�r�r�load)r�power�adjust�t�t3s     rr�zJpeg2KImageFile.load&s����9�9��������%�E��a�Z�F��T�Y�Y�q�\�F�*�e�3�4��T�Y�Y�q�\�F�*�e�3�4��D�J��	�	�!��A��A�$�q�'�4�<�<����a��d�1�g�q��t�A�w�G�B��A�$����� 2�A�a�D�"�=�>�D�I��"�"�'�'��-�-r)r9r:r;�format�format_descriptionr�r��propertyr��setterr��
__classcell__)r�s@rrxrx�sJ���
�F�0��2
�h6�,�.��.��]�]����.rrxc�&�|dddk(xs|dddk(S)NrGr{rr}r=)�prefixs r�_acceptr�7s+���r��
�)�)�	B��#�2�;�A�A�rc��|j}|jd�s|jdd�rd}nd}|jdd�}|jdd�}|jdd�}|jd	d
�}|jdd�}	|	�5t|	tt
f�rt
d�|	D��s
d
}
t|
��|jdd�}|jdd�}|jdd�}
|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}|jd�}t|t�r|j�}|jdd�}d}t|d�r	|j�}|||||	|||
||||||||f|_
tj||dd|j zd|fg�y#t$rd}Y�NwxYw)N�.j2k�no_jp2Fr|r~�offset�tile_offset�	tile_size�quality_mode�rates�quality_layersc3�HK�|]}t|ttf����y�wr")�
isinstancer��float)�.0�
quality_layers  r�	<genexpr>z_save.<locals>.<genexpr>Rs ����
�8E�J�}�s�E�l�3�
�s� "z,quality_layers must be a sequence of numbers�num_resolutionsr�codeblock_size�
precinct_size�irreversible�progression�LRCP�cinema_mode�no�mct�signedr��pltrr�r�r�)�encoderinfor��getr��list�tuple�all�
ValueError�str�encode�hasattrr�r��
encoderconfigr�_saver')�imr�filenamer��kindr�r�r�r�r�rr��	cblk_sizer�r�r�r�r�r�r�r�r�s                      rr�r�Bs	��
�>�>�D����� �D�H�H�X�u�$=�����
�X�X�h��
%�F��(�(�=�$�/�K�����d�+�I��8�8�N�G�4�L��X�X�.��5�N��!��>�D�%�=�1��
�IW�
�
�=����o���h�h�0�!�4�O����)�4�0�I��H�H�_�d�3�M��8�8�N�E�2�L��(�(�=�&�1�K��(�(�=�$�/�K�
�(�(�5�!�
�C�
�X�X�h��
&�F��h�h�y�!�G��'�3���.�.�"��
�(�(�5�%�
 �C�	�B��r�8��	�����B�
	�������������
���!�B��&�O�O�B��h�����(8�!�T�B�C�D��-�	��B�	�s�(G9�9H�H)z.jp2r�z.jpcz.jpfz.jpxz.j2cz	image/jp2)�
__future__rr*r3r#�rrrr	r[rbrvrxr�r��
register_openr��
register_save�register_extensions�
register_mimer=rr�<module>r�s��� #�	�	�
�'�'�G�G�T�D9�9%�@g.�i�)�)�g.�T�>E�J����O�*�*�O�W�E�����O�*�*�E�2��������L������O�*�*�K�8r

Zerion Mini Shell 1.0