ó
    ‰*£h‹(  ã                   óü   • S SK JrJrJr  S SKJrJrJr  S SKJ	r	   " S S\	5      r
 " S S5      r " S S	5      r " S
 S5      rS r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)é   )Ú	MIME_TYPEÚTIFF_FLDÚTIFF_TAG)Ú
BIG_ENDIANÚLITTLE_ENDIANÚStreamReader)ÚBaseImageHeaderc                   óH   • \ rS rSrSr\S 5       r\S 5       r\S 5       r	Sr
g)ÚTiffé   zXImage header parser for TIFF images.

Handles both big and little endian byte ordering.
c                 ó"   • [         R                  $ )zSReturn the MIME type of this TIFF image, unconditionally the string
``image/tiff``.)r   ÚTIFF©Úselfs    ÚL/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docx/image/tiff.pyÚcontent_typeÚTiff.content_type   s   € ô �~‰~Ðó    c                 ó   • g)z:Default filename extension, always 'tiff' for TIFF images.Útiff© r   s    r   Údefault_extÚTiff.default_ext   s   € ð r   c                 óž   • [         R                  U5      nUR                  nUR                  nUR                  nUR
                  nU " X4XV5      $ )zQReturn 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_streamÚTiff.from_stream   sG   € ô ×"Ñ" 6Ó*ˆà—?‘?ˆØ×$Ñ$ˆ	Ø—?‘?ˆØ—?‘?ˆá�8¨Ó;Ð;r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úpropertyr   r   Úclassmethodr$   Ú__static_attributes__r   r   r   r   r      sC   † ñð
 ñó ðð
 ñó ðð ñ
<ó ó
<r   r   c                   ó¢   ^ • \ rS rSrSrU 4S jr\S 5       r\S 5       r	\S 5       r
\S 5       r\S 5       r\S	 5       rS
 r\S 5       rSrU =r$ )r   é%   zgParses a TIFF image stream to extract the image properties found in its main
image file directory (IFD)c                 ó6   >• [         [        U ]  5         Xl        g ©N)Úsuperr   Ú__init__Ú_ifd_entries)r   Úifd_entriesÚ	__class__s     €r   r3   Ú_TiffParser.__init__)   s   ø€ ÜŒk˜4Ñ)Ô+Ø'Õr   c                 ó€   • U R                  U5      nUR                  S5      n[        R                  X#5      nU " U5      $ )zeReturn 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_offsetr5   s        r   r   Ú_TiffParser.parse-   s?   € ð ×,Ñ,¨VÓ4ˆ
Ø ×*Ñ*¨1Ó-ˆÜ!×-Ñ-¨jÓFˆÙ�;ÓÐr   c                 ó@   • U R                  [        R                  5      $ )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   Ú_TiffParser.horz_dpi6   ó   € ð �y‰yœ×.Ñ.Ó/Ð/r   c                 ó@   • U R                  [        R                  5      $ )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.)rA   r   ÚY_RESOLUTIONr   s    r   r    Ú_TiffParser.vert_dpi<   rD   r   c                 óT   • U R                   R                  [        R                  5      $ )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.)r4   Úgetr   ÚIMAGE_LENGTHr   s    r   r   Ú_TiffParser.px_heightB   s!   € ð
 × Ñ ×$Ñ$¤X×%:Ñ%:Ó;Ð;r   c                 óT   • U R                   R                  [        R                  5      $ )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.)r4   rI   r   ÚIMAGE_WIDTHr   s    r   r   Ú_TiffParser.px_widthI   s!   € ð
 × Ñ ×$Ñ$¤X×%9Ñ%9Ó:Ð:r   c                 ój   • UR                  S5        UR                  S5      nUS:X  a  [        $ [        $ )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_endianÚ_TiffParser._detect_endianP   s.   € ð 	�‰�AŒØ—[‘[ “^ˆ
Ø'¨5Ó0ŒzÐC´mÐCr   c                 ó¼   • U R                   nX;  a  gUR                  [        R                  S5      nUS:X  a  gUS:X  a  SOSnX!   n[	        [        XT-  5      5      $ )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   rQ   r   gR¸…ëQ@)r4   rI   r   ÚRESOLUTION_UNITÚintÚround)r   Úresolution_tagr5   Úresolution_unitÚunits_per_inchÚdots_per_units         r   rA   Ú_TiffParser._dpiX   sd   € ð ×'Ñ'ˆàÓ,Øð &Ÿ/™/¬(×*BÑ*BÀAÓFˆà˜aÓØà-°Ó2™¸ˆØ#Ñ3ˆÜ”5˜Ñ7Ó8Ó9Ð9r   c                 ó:   • U R                  U5      n[        X5      $ )z•Return a |StreamReader| instance with wrapping `stream` and having "endian-
ness" determined by the 'MM' or 'II' indicator in the TIFF stream header.)rU   r   )r!   r"   Úendians      r   r:   Ú_TiffParser._make_stream_readern   s   € ð ×#Ñ# FÓ+ˆÜ˜FÓ+Ð+r   )r4   )r&   r'   r(   r)   r*   r3   r,   r   r+   r   r    r   r   rU   rA   r:   r-   Ú__classcell__©r6   s   @r   r   r   %   s    ø† ñ"õ(ð ñ ó ð ð ñ0ó ð0ð
 ñ0ó ð0ð
 ñ<ó ð<ð ñ;ó ð;ð ñDó ðDò:ð, ñ,ó ö,r   r   c                   óR   ^ • \ rS rSrSrU 4S jrS rS r\S 5       r	S	S jr
SrU =r$ )
r<   év   zyImage File Directory for a TIFF image, having mapping (dict) semantics allowing
"tag" values to be retrieved by tag code.c                 ó6   >• [         [        U ]  5         Xl        g r1   )r2   r<   r3   Ú_entries)r   Úentriesr6   s     €r   r3   Ú_IfdEntries.__init__z   s   ø€ ÜŒk˜4Ñ)Ô+Ø�r   c                 ó8   • U R                   R                  U5      $ )z5Provides ``in`` operator, e.g. ``tag in ifd_entries``)ri   Ú__contains__©r   Úkeys     r   rm   Ú_IfdEntries.__contains__~   s   € à�}‰}×)Ñ)¨#Ó.Ð.r   c                 ó8   • U R                   R                  U5      $ )zCProvides indexed access, e.g. ``tag_value = ifd_entries[tag_code]``)ri   Ú__getitem__rn   s     r   rr   Ú_IfdEntries.__getitem__‚   s   € à�}‰}×(Ñ(¨Ó-Ð-r   c                 óš   • [        X5      nUR                  5        Vs0 s H  oDR                  UR                  _M     nnU " U5      $ s  snf )zNReturn a new |_IfdEntries| instance parsed from `stream` starting at
`offset`.)Ú
_IfdParserÚiter_entriesÚtagÚvalue)r!   r"   ÚoffsetÚ
ifd_parserÚerj   s         r   r$   Ú_IfdEntries.from_stream†   sG   € ô   Ó/ˆ
Ø+5×+BÑ+BÔ+DÓEÒ+D a—5‘5˜!Ÿ'™'’>Ñ+DˆÐEÙ�7‹|Ðùò Fs   ž Ac                 ó8   • U R                   R                  X5      $ )z`Return value of IFD entry having tag matching `tag_code`, or `default` if no
matching tag found.)ri   rI   )r   Útag_codeÚdefaults      r   rI   Ú_IfdEntries.getŽ   s   € ð �}‰}× Ñ  Ó3Ð3r   )ri   r1   )r&   r'   r(   r)   r*   r3   rm   rr   r,   r$   rI   r-   rd   re   s   @r   r<   r<   v   s5   ø† ñ1õ ò/ò.ð ñó ð÷4ò 4r   r<   c                   óB   ^ • \ rS rSrSrU 4S jrS r\S 5       rSr	U =r
$ )ru   é”   z]Service object that knows how to extract directory entries from an Image File
Directory (IFD)c                 óB   >• [         [        U ]  5         Xl        X l        g r1   )r2   ru   r3   Ú_stream_rdrÚ_offset)r   r=   ry   r6   s      €r   r3   Ú_IfdParser.__init__˜   s   ø€ ÜŒj˜$Ñ(Ô*Ø%ÔØ�r   c              #   ó¢   #   • [        U R                  5       H2  nU R                  S-   US-  -   n[        U R                  U5      nUv •  M4     g7f)zNGenerate an |_IfdEntry| instance corresponding to each entry in the
directory.rQ   é   N)ÚrangeÚ_entry_countr…   Ú_IfdEntryFactoryr„   )r   ÚidxÚdir_entry_offsetÚ	ifd_entrys       r   rv   Ú_IfdParser.iter_entries�   sL   é € ô ˜×*Ñ*Ö+ˆCØ#Ÿ|™|¨aÑ/°3¸±8Ñ<ÐÜ(¨×)9Ñ)9Ð;KÓLˆIØŒOò ,ùs   ‚AAc                 óL   • U R                   R                  U R                  5      $ )zDThe count of directory entries, read from the top of the IFD header.)r„   Ú
read_shortr…   r   s    r   rŠ   Ú_IfdParser._entry_count¥   s   € ð ×Ñ×*Ñ*¨4¯<©<Ó8Ð8r   )r…   r„   )r&   r'   r(   r)   r*   r3   rv   r+   rŠ   r-   rd   re   s   @r   ru   ru   ”   s&   ø† ñõò
ð ñ9ó ö9r   ru   c                 ó  • [         R                  [        [         R                  [        [         R
                  [        [         R                  [        0nU R                  US5      nUR                  U[        5      nUR                  X5      $ )zpReturn an |_IfdEntry| subclass instance containing the value of the directory
entry at `offset` in `stream_rdr`.rQ   )r   ÚASCIIÚ_AsciiIfdEntryÚSHORTÚ_ShortIfdEntryÚLONGÚ_LongIfdEntryÚRATIONALÚ_RationalIfdEntryr‘   rI   Ú	_IfdEntryr$   )r=   ry   Úifd_entry_classesÚ
field_typeÚEntryClss        r   r‹   r‹   «   sj   € ô 	�‰œÜ�‰œÜ�‰”}Ü×ÑÔ,ð	Ðð ×&Ñ& v¨qÓ1€JØ ×$Ñ$ Z´Ó;€HØ×Ñ 
Ó3Ð3r   c                   ól   ^ • \ rS rSrSrU 4S jr\S 5       r\S 5       r\	S 5       r
\	S 5       rSrU =r$ )	rœ   é¹   zkBase class for IFD entry classes.

Subclasses are differentiated by value type, e.g. ASCII, long int, etc.
c                 óB   >• [         [        U ]  5         Xl        X l        g r1   )r2   rœ   r3   Ú	_tag_codeÚ_value)r   r~   rx   r6   s      €r   r3   Ú_IfdEntry.__init__¿   s   ø€ ÜŒi˜Ñ'Ô)Ø!ŒØ�r   c                 ó¢   • UR                  US5      nUR                  US5      nUR                  US5      nU R                  XXE5      nU " X65      $ )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.
rP   r9   é   )r‘   r;   Ú_parse_value)r!   r=   ry   r~   Úvalue_countÚvalue_offsetrx   s          r   r$   Ú_IfdEntry.from_streamÄ   sW   € ð ×(Ñ(¨°Ó3ˆØ ×*Ñ*¨6°1Ó5ˆØ!×+Ñ+¨F°AÓ6ˆØ× Ñ  °[ÓOˆÙ�8Ó#Ð#r   c                 ó   • g)zoReturn the value of this field parsed from `stream_rdr` at `offset`.

Intended to be overridden by subclasses.
zUNIMPLEMENTED FIELD TYPEr   ©r!   r=   ry   r©   rª   s        r   r¨   Ú_IfdEntry._parse_valueÒ   s   € ð *r   c                 ó   • U R                   $ )z.Short int code that identifies this IFD entry.)r£   r   s    r   rw   Ú_IfdEntry.tagÚ   s   € ð �~‰~Ðr   c                 ó   • U R                   $ )z7Value of this tag, its type being dependent on the tag.)r¤   r   s    r   rx   Ú_IfdEntry.valueß   s   € ð �{‰{Ðr   )r£   r¤   )r&   r'   r(   r)   r*   r3   r,   r$   r¨   r+   rw   rx   r-   rd   re   s   @r   rœ   rœ   ¹   s]   ø† ñõ
ð
 ñ$ó ð$ð ñ*ó ð*ð ñó ðð ñó ör   rœ   c                   ó(   • \ rS rSrSr\S 5       rSrg)r•   éå   z<IFD entry having the form of a NULL-terminated ASCII string.c                 ó,   • UR                  US-
  U5      $ )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¨   Ú_AsciiIfdEntry._parse_valueè   s   € ð ×"Ñ" ;°¡?°LÓAÐAr   r   N©r&   r'   r(   r)   r*   r,   r¨   r-   r   r   r   r•   r•   å   s   † ÙFàñBó óBr   r•   c                   ó(   • \ rS rSrSr\S 5       rSrg)r—   éò   z0IFD entry expressed as a short (2-byte) integer.c                 ó4   • US:X  a  UR                  US5      $ g)zyReturn 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¨   Ú_ShortIfdEntry._parse_valueõ   s"   € ð ˜!ÓØ×(Ñ(¨°Ó3Ð3à>r   r   Nr¸   r   r   r   r—   r—   ò   s   † Ù:àñ	?ó ó	?r   r—   c                   ó(   • \ rS rSrSr\S 5       rSrg)r™   i  z/IFD entry expressed as a long (4-byte) integer.c                 ó4   • US:X  a  UR                  US5      $ g)zxReturn 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©r;   r­   s        r   r¨   Ú_LongIfdEntry._parse_value  s"   € ð ˜!ÓØ×'Ñ'¨°Ó2Ð2à=r   r   Nr¸   r   r   r   r™   r™     s   † Ù9àñ	>ó ó	>r   r™   c                   ó(   • \ rS rSrSr\S 5       rSrg)r›   i  z5IFD entry expressed as a numerator, denominator pair.c                 ó^   • US:X  a'  UR                  U5      nUR                  US5      nXV-  $ g)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   r9   z$Multi-value Rational NOT IMPLEMENTEDr¿   )r!   r=   ry   r©   rª   Ú	numeratorÚdenominators          r   r¨   Ú_RationalIfdEntry._parse_value  s:   € ð ˜!ÓØ"×,Ñ,¨\Ó:ˆIØ$×.Ñ.¨|¸QÓ?ˆKØÑ*Ð*à9r   r   Nr¸   r   r   r   r›   r›     s   † Ù?àñ:ó ó:r   r›   N)Ú	constantsr   r   r   Úhelpersr   r   r   Úimager	   r   r   r<   ru   r‹   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   