Ë
    \Rði‹(  ã                   óü   — 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y)é   )Ú	MIME_TYPEÚTIFF_FLDÚTIFF_TAG)Ú
BIG_ENDIANÚLITTLE_ENDIANÚStreamReader)ÚBaseImageHeaderc                   ó@   — e Zd ZdZed„ «       Zed„ «       Zed„ «       Zy)Ú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    úJ/var/www/html/Extract/venv/lib/python3.12/site-packages/docx/image/tiff.pyÚcontent_typezTiff.content_type   s   € ô �~‰~Ðó    c                  ó   — y)z:Default filename extension, always 'tiff' for TIFF images.Útiff© r   s    r   Údefault_extzTiff.default_ext   s   € ð r   c                 ó¢   — t         j                  |«      }|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   sK   € ô ×"Ñ" 6Ó*ˆà—?‘?ˆØ×$Ñ$ˆ	Ø—?‘?ˆØ—?‘?ˆá�8˜Y¨°(Ó;Ð;r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   Úclassmethodr!   r   r   r   r   r      sC   „ ñð
 ñó ðð
 ñó ðð ñ
<ó ñ
<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                 ó8   •— t         t        | �  «        || _        y ©N)Úsuperr   Ú__init__Ú_ifd_entries)r   Úifd_entriesÚ	__class__s     €r   r,   z_TiffParser.__init__)   s   ø€ ÜŒk˜4Ñ)Ô+Ø'ˆÕr   c                 ó‚   — | j                  |«      }|j                  d«      }t        j                  ||«      } | |«      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-   sA   € ð ×,Ñ,¨VÓ4ˆ
Ø ×*Ñ*¨1Ó-ˆÜ!×-Ñ-¨j¸+ÓFˆÙ�;ÓÐr   c                 ó@   — | j                  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                 ó@   — | j                  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                 óT   — | 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                 óT   — | 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Ñ%9Ó:Ð:r   c                 óh   — |j                  d«       |j                  d«      }|dk(  rt        S 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   s.   € ð 	�‰�AŒØ—[‘[ “^ˆ
Ø'¨5Ò0ŒzÐC´mÐCr   c                 óº   — | j                   }||vry|j                  t        j                  d«      }|dk(  ry|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   sj   € ð ×'Ñ'ˆà Ñ,Øð &Ÿ/™/¬(×*BÑ*BÀAÓFˆà˜aÒØà-°Ò2™¸ˆØ# NÑ3ˆÜ”5˜¨Ñ7Ó8Ó9Ð9r   c                 ó<   — | j                  |«      }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ð
 ñ0ó ð0ð
 ñ<ó ð<ð ñ;ó ð;ð ñDó ðDò:ð, ñ,ó ô,r   r   c                   óF   ‡ — 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                 ó8   •— t         t        | �  «        || _        y r*   )r+   r4   r,   Ú_entries)r   Úentriesr/   s     €r   r,   z_IfdEntries.__init__z   s   ø€ ÜŒk˜4Ñ)Ô+Øˆ�r   c                 ó8   — | j                   j                  |«      S )z5Provides ``in`` operator, e.g. ``tag in ifd_entries``)rX   Ú__contains__©r   Úkeys     r   r[   z_IfdEntries.__contains__~   s   € à�}‰}×)Ñ)¨#Ó.Ð.r   c                 ó8   — | j                   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        ||«      }|j                  «       D �ci c]  }|j                  |j                  “Œ }} | |«      S c c}w )zVReturn a new |_IfdEntries| instance parsed from `stream` starting at
        `offset`.)Ú
_IfdParserÚiter_entriesÚtagÚvalue)r   r   ÚoffsetÚ
ifd_parserÚerY   s         r   r!   z_IfdEntries.from_stream†   sH   € ô   ¨Ó/ˆ
Ø+5×+BÑ+BÓ+DÖE a�1—5‘5˜!Ÿ'™'‘>ÐEˆÐEÙ�7‹|Ðùò Fs   ŸAc                 ó:   — | j                   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Ð3r   r*   )r"   r#   r$   r%   r,   r[   r_   r'   r!   r>   rT   rU   s   @r   r4   r4   v   s0   ø„ ñ1ô ò/ò.ð ñó ð÷4r   r4   c                   ó8   ‡ — e Zd ZdZˆ fd„Zd„ Zed„ «       Zˆ xZS )ra   zaService object that knows how to extract directory entries from an Image File
    Directory (IFD)c                 óF   •— t         t        | �  «        || _        || _        y r*   )r+   ra   r,   Ú_stream_rdrÚ_offset)r   r5   re   r/   s      €r   r,   z_IfdParser.__init__˜   s   ø€ ÜŒj˜$Ñ(Ô*Ø%ˆÔØˆ�r   c              #   óž   K  — t        | j                  «      D ]1  }| j                  dz   |dz  z   }t        | j                  |«      }|–— Œ3 y­w)zVGenerate an |_IfdEntry| instance corresponding to each entry in the
        directory.rD   é   N)ÚrangeÚ_entry_countrn   Ú_IfdEntryFactoryrm   )r   ÚidxÚdir_entry_offsetÚ	ifd_entrys       r   rb   z_IfdParser.iter_entries�   sR   è ø€ ô ˜×*Ñ*Ó+ò 	ˆCØ#Ÿ|™|¨aÑ/°3¸±8Ñ<ÐÜ(¨×)9Ñ)9Ð;KÓLˆIØ‹Oñ	ùs   ‚AAc                 óL   — | j                   j                  | j                  «      S )zDThe count of directory entries, read from the top of the IFD header.)rm   Ú
read_shortrn   r   s    r   rr   z_IfdParser._entry_count¥   s   € ð ×Ñ×*Ñ*¨4¯<©<Ó8Ð8r   )	r"   r#   r$   r%   r,   rb   r&   rr   rT   rU   s   @r   ra   ra   ”   s&   ø„ ñôò
ð ñ9ó ô9r   ra   c                 ó  — t         j                  t        t         j                  t        t         j
                  t        t         j                  t        i}| j                  |d«      }|j                  |t        «      }|j                  | |«      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Ú_RationalIfdEntryrx   r>   Ú	_IfdEntryr!   )r5   re   Úifd_entry_classesÚ
field_typeÚEntryClss        r   rs   rs   «   sl   € ô 	�‰œÜ�‰œÜ�‰”}Ü×ÑÔ,ð	Ðð ×&Ñ& v¨qÓ1€JØ ×$Ñ$ Z´Ó;€HØ×Ñ 
¨FÓ3Ð3r   c                   ób   ‡ — 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                 óF   •— t         t        | �  «        || _        || _        y r*   )r+   r‚   r,   Ú	_tag_codeÚ_value)r   ri   rd   r/   s      €r   r,   z_IfdEntry.__init__¿   s   ø€ ÜŒi˜Ñ'Ô)Ø!ˆŒØˆ�r   c                 ó¨   — |j                  |d«      }|j                  |d«      }|j                  |d«      }| j                  ||||«      } | ||«      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   é   )rx   r3   Ú_parse_value)r   r5   re   ri   Úvalue_countÚvalue_offsetrd   s          r   r!   z_IfdEntry.from_streamÄ   s]   € ð ×(Ñ(¨°Ó3ˆØ ×*Ñ*¨6°1Ó5ˆØ!×+Ñ+¨F°AÓ6ˆØ× Ñ  ¨V°[À,ÓOˆÙ�8˜UÓ#Ð#r   c                  ó   — y)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   re   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   rc   z_IfdEntry.tagÚ   s   € ð �~‰~Ðr   c                 ó   — | j                   S )z7Value of this tag, its type being dependent on the tag.)r‰   r   s    r   rd   z_IfdEntry.valueß   s   € ð �{‰{Ðr   )r"   r#   r$   r%   r,   r'   r!   rŒ   r&   rc   rd   rT   rU   s   @r   r‚   r‚   ¹   s]   ø„ ñô
ð
 ñ$ó ð$ð ñ*ó ð*ð ñó ðð ñó ôr   r‚   c                   ó    — e Zd ZdZed„ «       Zy)r{   z<IFD entry having the form of a NULL-terminated ASCII string.c                 ó,   — |j                  |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ÐAr   N©r"   r#   r$   r%   r'   rŒ   r   r   r   r{   r{   å   s   „ ÙFàñBó ñBr   r{   c                   ó    — e Zd ZdZed„ «       Zy)r}   z0IFD entry expressed as a short (2-byte) integer.c                 ó2   — |dk(  r|j                  |d«      S y)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)rx   r�   s        r   rŒ   z_ShortIfdEntry._parse_valueõ   s"   € ð ˜!ÒØ×(Ñ(¨°Ó3Ð3à>r   Nr–   r   r   r   r}   r}   ò   s   „ Ù:àñ	?ó ñ	?r   r}   c                   ó    — e Zd ZdZed„ «       Zy)r   z/IFD entry expressed as a long (4-byte) integer.c                 ó2   — |dk(  r|j                  |d«      S y)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à=r   Nr–   r   r   r   r   r     s   „ Ù9àñ	>ó ñ	>r   r   c                   ó    — e Zd ZdZed„ «       Zy)r�   z5IFD entry expressed as a numerator, denominator pair.c                 ó^   — |dk(  r(|j                  |«      }|j                  |d«      }||z  S y)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   re   r�   rŽ   Ú	numeratorÚdenominators          r   rŒ   z_RationalIfdEntry._parse_value  s<   € ð ˜!ÒØ"×,Ñ,¨\Ó:ˆIØ$×.Ñ.¨|¸QÓ?ˆKØ˜{Ñ*Ð*à9r   Nr–   r   r   r   r�   r�     s   „ Ù?àñ:ó ñ:r   r�   N)Ú	constantsr   r   r   Úhelpersr   r   r   Úimager	   r   r   r4   ra   rs   r‚   r{   r}   r   r�   r   r   r   ú<module>r£      sƒ   ðß 4Ñ 4ß <Ñ <Ý "ô<ˆ?ô <÷>N,ñ N,÷b4ñ 4÷<9ñ 9ò.4÷)ñ )ôX
B�Yô 
Bô?�Yô ?ô >�Iô >ô :˜	õ :r   