§
    £”j‹(  ã                   ó4  — d dl mZmZmZ d dlmZmZmZ d dlm	Z	  G d„ de	¦  «        Z
 G d„ d¦  «        Z G d„ d	¦  «        Z G d
„ d¦  «        Zd„ Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )é   )Ú	MIME_TYPEÚTIFF_FLDÚTIFF_TAG)Ú
BIG_ENDIANÚLITTLE_ENDIANÚStreamReader)ÚBaseImageHeaderc                   óT   — e Zd ZdZed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         ZdS )ÚTiffz`Image header parser for TIFF images.

    Handles both big and little endian byte ordering.
    c                 ó   — t           j        S )z[Return the MIME type of this TIFF image, unconditionally the string
        ``image/tiff``.)r   ÚTIFF©Úselfs    ú^/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/docx/image/tiff.pyÚcontent_typezTiff.content_type   s   € õ Œ~Ðó    c                 ó   — dS )z:Default filename extension, always 'tiff' for TIFF images.Útiff© r   s    r   Údefault_extzTiff.default_ext   s	   € ð ˆvr   c                 óŠ   — t                                |¦  «        }|j        }|j        }|j        }|j        } | ||||¦  «        S )zYReturn a |Tiff| instance containing the properties of the TIFF image in
        `stream`.)Ú_TiffParserÚparseÚpx_widthÚ	px_heightÚhorz_dpiÚvert_dpi)ÚclsÚstreamÚparserr   r   r   r   s          r   Úfrom_streamzTiff.from_stream   sJ   € õ ×"Ò" 6Ñ*Ô*ˆà”?ˆØÔ$ˆ	Ø”?ˆØ”?ˆàˆs�8˜Y¨°(Ñ;Ô;Ð;r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   Úclassmethodr!   r   r   r   r   r      so   € € € € € ðð ð
 ðð ñ „Xðð
 ðð ñ „Xðð ð
<ð 
<ñ „[ð
<ð 
<ð 
<r   r   c                   óÂ   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
ed„ ¦   «         Zed„ ¦   «         Zd	„ Zed
„ ¦   «         Zˆ xZS )r   zkParses a TIFF image stream to extract the image properties found in its main
    image file directory (IFD)c                 ód   •— t          t          | ¦  «                             ¦   «          || _        d S ©N)Úsuperr   Ú__init__Ú_ifd_entries)r   Úifd_entriesÚ	__class__s     €r   r,   z_TiffParser.__init__)   s-   ø€ Ý�k˜4Ñ Ô ×)Ò)Ñ+Ô+Ð+Ø'ˆÔÐÐr   c                 ó¢   — |                       |¦  «        }|                     d¦  «        }t                               ||¦  «        } | |¦  «        S )zmReturn an instance of |_TiffParser| containing the properties parsed from the
        TIFF image in `stream`.é   )Ú_make_stream_readerÚ	read_longÚ_IfdEntriesr!   )r   r   Ú
stream_rdrÚifd0_offsetr.   s        r   r   z_TiffParser.parse-   sO   € ð ×,Ò,¨VÑ4Ô4ˆ
Ø ×*Ò*¨1Ñ-Ô-ˆÝ!×-Ò-¨j¸+ÑFÔFˆØˆs�;ÑÔÐr   c                 ó@   — |                       t          j        ¦  «        S )zœThe horizontal dots per inch value calculated from the XResolution and
        ResolutionUnit tags of the IFD; defaults to 72 if those tags are not present.)Ú_dpir   ÚX_RESOLUTIONr   s    r   r   z_TiffParser.horz_dpi6   ó   € ð �yŠy�Ô.Ñ/Ô/Ð/r   c                 ó@   — |                       t          j        ¦  «        S )zšThe vertical dots per inch value calculated from the XResolution and
        ResolutionUnit tags of the IFD; defaults to 72 if those tags are not present.)r8   r   ÚY_RESOLUTIONr   s    r   r   z_TiffParser.vert_dpi<   r:   r   c                 óJ   — | j                              t          j        ¦  «        S )z²The number of stacked rows of pixels in the image, |None| if the IFD contains
        no ``ImageLength`` tag, the expected case when the TIFF is embeded in an Exif
        image.)r-   Úgetr   ÚIMAGE_LENGTHr   s    r   r   z_TiffParser.px_heightB   s   € ð
 Ô ×$Ò$¥XÔ%:Ñ;Ô;Ð;r   c                 óJ   — | j                              t          j        ¦  «        S )z­The number of pixels in each row in the image, |None| if the IFD contains no
        ``ImageWidth`` tag, the expected case when the TIFF is embeded in an Exif
        image.)r-   r>   r   ÚIMAGE_WIDTHr   s    r   r   z_TiffParser.px_widthI   s   € ð
 Ô ×$Ò$¥XÔ%9Ñ:Ô:Ð:r   c                 ó~   — |                      d¦  «         |                     d¦  «        }|dk    rt          nt          S )z‹Return either BIG_ENDIAN or LITTLE_ENDIAN depending on the endian indicator
        found in the TIFF `stream` header, either 'MM' or 'II'.é    é   s   MM)ÚseekÚreadr   r   )r   r   Ú
endian_strs      r   Ú_detect_endianz_TiffParser._detect_endianP   s6   € ð 	�Š�A‰ŒˆØ—[’[ ‘^”^ˆ
Ø'¨5Ò0Ð0�zˆzµmÐCr   c                 óÎ   — | j         }||vrdS |                     t          j        d¦  «        }|dk    rdS |dk    rdnd}||         }t	          t          ||z  ¦  «        ¦  «        S )a!  Return the dpi value calculated for `resolution_tag`, which can be either
        TIFF_TAG.X_RESOLUTION or TIFF_TAG.Y_RESOLUTION.

        The calculation is based on the values of both that tag and the
        TIFF_TAG.RESOLUTION_UNIT tag in this parser's |_IfdEntries| instance.
        éH   rD   r   gR¸…ëQ@)r-   r>   r   ÚRESOLUTION_UNITÚintÚround)r   Úresolution_tagr.   Úresolution_unitÚunits_per_inchÚdots_per_units         r   r8   z_TiffParser._dpiX   s|   € ð Ô'ˆà Ð,Ð,Ø�2ð &Ÿ/š/­(Ô*BÀAÑFÔFˆà˜aÒÐØ�2à-°Ò2Ð2˜˜¸ˆØ# NÔ3ˆÝ•5˜¨Ñ7Ñ8Ô8Ñ9Ô9Ð9r   c                 óL   — |                       |¦  «        }t          ||¦  «        S )z�Return a |StreamReader| instance with wrapping `stream` and having "endian-
        ness" determined by the 'MM' or 'II' indicator in the TIFF stream header.)rH   r   )r   r   Úendians      r   r2   z_TiffParser._make_stream_readern   s'   € ð ×#Ò# FÑ+Ô+ˆÝ˜F FÑ+Ô+Ð+r   )r"   r#   r$   r%   r,   r'   r   r&   r   r   r   r   rH   r8   r2   Ú__classcell__©r/   s   @r   r   r   %   s  ø€ € € € € ð"ð "ð(ð (ð (ð (ð (ð ð ð  ñ „[ð ð ð0ð 0ñ „Xð0ð
 ð0ð 0ñ „Xð0ð
 ð<ð <ñ „Xð<ð ð;ð ;ñ „Xð;ð ðDð Dñ „[ðDð:ð :ð :ð, ð,ð ,ñ „[ð,ð ,ð ,ð ,ð ,r   r   c                   óL   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zed„ ¦   «         Zdd„Z	ˆ xZ
S )	r4   z}Image File Directory for a TIFF image, having mapping (dict) semantics allowing
    "tag" values to be retrieved by tag code.c                 ód   •— t          t          | ¦  «                             ¦   «          || _        d S r*   )r+   r4   r,   Ú_entries)r   Úentriesr/   s     €r   r,   z_IfdEntries.__init__z   s*   ø€ Ý�k˜4Ñ Ô ×)Ò)Ñ+Ô+Ð+ØˆŒˆˆr   c                 ó6   — | j                              |¦  «        S )z5Provides ``in`` operator, e.g. ``tag in ifd_entries``)rX   Ú__contains__©r   Úkeys     r   r[   z_IfdEntries.__contains__~   s   € àŒ}×)Ò)¨#Ñ.Ô.Ð.r   c                 ó6   — | j                              |¦  «        S )zCProvides indexed access, e.g. ``tag_value = ifd_entries[tag_code]``)rX   Ú__getitem__r\   s     r   r_   z_IfdEntries.__getitem__‚   s   € àŒ}×(Ò(¨Ñ-Ô-Ð-r   c                 ót   — t          ||¦  «        }d„ |                     ¦   «         D ¦   «         } | |¦  «        S )zVReturn a new |_IfdEntries| instance parsed from `stream` starting at
        `offset`.c                 ó(   — i | ]}|j         |j        “ŒS r   )ÚtagÚvalue)Ú.0Úes     r   ú
<dictcomp>z+_IfdEntries.from_stream.<locals>.<dictcomp>‹   s   € ÐEÐEÐE a�1”5˜!œ'ÐEÐEÐEr   )Ú
_IfdParserÚiter_entries)r   r   ÚoffsetÚ
ifd_parserrY   s        r   r!   z_IfdEntries.from_stream†   s@   € õ   ¨Ñ/Ô/ˆ
ØEÐE¨:×+BÒ+BÑ+DÔ+DÐEÑEÔEˆØˆs�7‰|Œ|Ðr   Nc                 ó8   — | j                              ||¦  «        S )zhReturn value of IFD entry having tag matching `tag_code`, or `default` if no
        matching tag found.)rX   r>   )r   Útag_codeÚdefaults      r   r>   z_IfdEntries.getŽ   s   € ð Œ}× Ò  ¨7Ñ3Ô3Ð3r   r*   )r"   r#   r$   r%   r,   r[   r_   r'   r!   r>   rT   rU   s   @r   r4   r4   v   s�   ø€ € € € € ð1ð 1ð ð  ð  ð  ð  ð/ð /ð /ð.ð .ð .ð ðð ñ „[ðð4ð 4ð 4ð 4ð 4ð 4ð 4ð 4r   r4   c                   ó>   ‡ — e Zd ZdZˆ fd„Zd„ Zed„ ¦   «         Zˆ xZS )rg   zaService object that knows how to extract directory entries from an Image File
    Directory (IFD)c                 ór   •— t          t          | ¦  «                             ¦   «          || _        || _        d S r*   )r+   rg   r,   Ú_stream_rdrÚ_offset)r   r5   ri   r/   s      €r   r,   z_IfdParser.__init__˜   s2   ø€ Ý�j˜$ÑÔ×(Ò(Ñ*Ô*Ð*Ø%ˆÔØˆŒˆˆr   c              #   óŠ   K  — t          | j        ¦  «        D ]+}| j        dz   |dz  z   }t          | j        |¦  «        }|V — Œ,dS )zVGenerate an |_IfdEntry| instance corresponding to each entry in the
        directory.rD   é   N)ÚrangeÚ_entry_countrq   Ú_IfdEntryFactoryrp   )r   ÚidxÚdir_entry_offsetÚ	ifd_entrys       r   rh   z_IfdParser.iter_entries�   s`   è è € õ ˜Ô*Ñ+Ô+ð 	ð 	ˆCØ#œ|¨aÑ/°3¸±8Ñ<ÐÝ(¨Ô)9Ð;KÑLÔLˆIØˆOˆOˆOˆOð	ð 	r   c                 ó@   — | j                              | j        ¦  «        S )zDThe count of directory entries, read from the top of the IFD header.)rp   Ú
read_shortrq   r   s    r   ru   z_IfdParser._entry_count¥   s   € ð Ô×*Ò*¨4¬<Ñ8Ô8Ð8r   )	r"   r#   r$   r%   r,   rh   r&   ru   rT   rU   s   @r   rg   rg   ”   sl   ø€ € € € € ðð ðð ð ð ð ð
ð ð ð ð9ð 9ñ „Xð9ð 9ð 9ð 9ð 9r   rg   c                 ó  — t           j        t          t           j        t          t           j        t          t           j        t          i}|  	                    |d¦  «        }| 
                    |t          ¦  «        }|                     | |¦  «        S )ztReturn an |_IfdEntry| subclass instance containing the value of the directory
    entry at `offset` in `stream_rdr`.rD   )r   ÚASCIIÚ_AsciiIfdEntryÚSHORTÚ_ShortIfdEntryÚLONGÚ_LongIfdEntryÚRATIONALÚ_RationalIfdEntryr{   r>   Ú	_IfdEntryr!   )r5   ri   Úifd_entry_classesÚ
field_typeÚEntryClss        r   rv   rv   «   sl   € õ 	Œ�ÝŒ�ÝŒ•}ÝÔÕ,ð	Ðð ×&Ò& v¨qÑ1Ô1€JØ ×$Ò$ ZµÑ;Ô;€HØ×Ò 
¨FÑ3Ô3Ð3r   c                   óz   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
ˆ xZS )r…   zsBase class for IFD entry classes.

    Subclasses are differentiated by value type, e.g. ASCII, long int, etc.
    c                 ór   •— t          t          | ¦  «                             ¦   «          || _        || _        d S r*   )r+   r…   r,   Ú	_tag_codeÚ_value)r   rl   rc   r/   s      €r   r,   z_IfdEntry.__init__¿   s1   ø€ Ý�i˜ÑÔ×'Ò'Ñ)Ô)Ð)Ø!ˆŒØˆŒˆˆr   c                 óÎ   — |                      |d¦  «        }|                     |d¦  «        }|                     |d¦  «        }|                      ||||¦  «        } | ||¦  «        S )a!  Return an |_IfdEntry| subclass instance containing the tag and value of the
        tag parsed from `stream_rdr` at `offset`.

        Note this method is common to all subclasses. Override the ``_parse_value()``
        method to provide distinctive behavior based on field type.
        rC   r1   é   )r{   r3   Ú_parse_value)r   r5   ri   rl   Úvalue_countÚvalue_offsetrc   s          r   r!   z_IfdEntry.from_streamÄ   sn   € ð ×(Ò(¨°Ñ3Ô3ˆØ ×*Ò*¨6°1Ñ5Ô5ˆØ!×+Ò+¨F°AÑ6Ô6ˆØ× Ò  ¨V°[À,ÑOÔOˆØˆs�8˜UÑ#Ô#Ð#r   c                 ó   — dS )zReturn the value of this field parsed from `stream_rdr` at `offset`.

        Intended to be overridden by subclasses.
        zUNIMPLEMENTED FIELD TYPEr   ©r   r5   ri   r�   r‘   s        r   r�   z_IfdEntry._parse_valueÒ   s
   € ð *Ð)r   c                 ó   — | j         S )z.Short int code that identifies this IFD entry.)r‹   r   s    r   rb   z_IfdEntry.tagÚ   s   € ð Œ~Ðr   c                 ó   — | j         S )z7Value of this tag, its type being dependent on the tag.)rŒ   r   s    r   rc   z_IfdEntry.valueß   s   € ð Œ{Ðr   )r"   r#   r$   r%   r,   r'   r!   r�   r&   rb   rc   rT   rU   s   @r   r…   r…   ¹   s®   ø€ € € € € ðð ð
ð ð ð ð ð
 ð$ð $ñ „[ð$ð ð*ð *ñ „[ð*ð ðð ñ „Xðð ðð ñ „Xðð ð ð ð r   r…   c                   ó(   — e Zd ZdZed„ ¦   «         ZdS )r~   z<IFD entry having the form of a NULL-terminated ASCII string.c                 ó4   — |                      |dz
  |¦  «        S )z¹Return the ASCII string parsed from `stream_rdr` at `value_offset`.

        The length of the string, including a terminating ' ' (NUL) character, is in
        `value_count`.
        r   )Úread_strr“   s        r   r�   z_AsciiIfdEntry._parse_valueè   s   € ð ×"Ò" ;°¡?°LÑAÔAÐAr   N©r"   r#   r$   r%   r'   r�   r   r   r   r~   r~   å   s8   € € € € € ØFÐFàðBð Bñ „[ðBð Bð Br   r~   c                   ó(   — e Zd ZdZed„ ¦   «         ZdS )r€   z0IFD entry expressed as a short (2-byte) integer.c                 ó>   — |dk    r|                      |d¦  «        S dS )z‘Return the short int value contained in the `value_offset` field of this
        entry.

        Only supports single values at present.
        r   rŽ   z)Multi-value short integer NOT IMPLEMENTED)r{   r“   s        r   r�   z_ShortIfdEntry._parse_valueõ   s+   € ð ˜!ÒÐØ×(Ò(¨°Ñ3Ô3Ð3à>Ð>r   Nr™   r   r   r   r€   r€   ò   s3   € € € € € Ø:Ð:àð	?ð 	?ñ „[ð	?ð 	?ð 	?r   r€   c                   ó(   — e Zd ZdZed„ ¦   «         ZdS )r‚   z/IFD entry expressed as a long (4-byte) integer.c                 ó>   — |dk    r|                      |d¦  «        S dS )z�Return the long int value contained in the `value_offset` field of this
        entry.

        Only supports single values at present.
        r   rŽ   z(Multi-value long integer NOT IMPLEMENTED©r3   r“   s        r   r�   z_LongIfdEntry._parse_value  s+   € ð ˜!ÒÐØ×'Ò'¨°Ñ2Ô2Ð2à=Ð=r   Nr™   r   r   r   r‚   r‚     s3   € € € € € Ø9Ð9àð	>ð 	>ñ „[ð	>ð 	>ð 	>r   r‚   c                   ó(   — e Zd ZdZed„ ¦   «         ZdS )r„   z5IFD entry expressed as a numerator, denominator pair.c                 ór   — |dk    r0|                      |¦  «        }|                      |d¦  «        }||z  S dS )z³Return the rational (numerator / denominator) value at `value_offset` in
        `stream_rdr` as a floating-point number.

        Only supports single values at present.
        r   r1   z$Multi-value Rational NOT IMPLEMENTEDrž   )r   r5   ri   r�   r‘   Ú	numeratorÚdenominators          r   r�   z_RationalIfdEntry._parse_value  sH   € ð ˜!ÒÐØ"×,Ò,¨\Ñ:Ô:ˆIØ$×.Ò.¨|¸QÑ?Ô?ˆKØ˜{Ñ*Ð*à9Ð9r   Nr™   r   r   r   r„   r„     s3   € € € € € Ø?Ð?àð:ð :ñ „[ð:ð :ð :r   r„   N)Ú	constantsr   r   r   Úhelpersr   r   r   Úimager	   r   r   r4   rg   rv   r…   r~   r€   r‚   r„   r   r   r   ú<module>r¦      sð  ðØ 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø "Ð "Ð "Ð "Ð "Ð "ð<ð <ð <ð <ð <ˆ?ñ <ô <ð <ð>N,ð N,ð N,ð N,ð N,ñ N,ô N,ð N,ðb4ð 4ð 4ð 4ð 4ñ 4ô 4ð 4ð<9ð 9ð 9ð 9ð 9ñ 9ô 9ð 9ð.4ð 4ð 4ð)ð )ð )ð )ð )ñ )ô )ð )ðX
Bð 
Bð 
Bð 
Bð 
B�Yñ 
Bô 
Bð 
Bð?ð ?ð ?ð ?ð ?�Yñ ?ô ?ð ?ð >ð >ð >ð >ð >�Iñ >ô >ð >ð :ð :ð :ð :ð :˜	ñ :ô :ð :ð :ð :r   