+
    i(                         ^RI HtHtHt ^RIHtHtHt ^RIH	t	  ! R R]	4      t
 ! R R4      t ! R R	4      t ! R
 R4      tR t ! R R4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )   )	MIME_TYPETIFF_FLDTIFF_TAG)
BIG_ENDIANLITTLE_ENDIANStreamReader)BaseImageHeaderc                   T   a  ] tR t^t o Rt]R 4       t]R 4       t]R 4       t	Rt
V tR# )TiffzXImage header parser for TIFF images.

Handles both big and little endian byte ordering.
c                "    \         P                  # )zSReturn the MIME type of this TIFF image, unconditionally the string
``image/tiff``.)r   TIFFselfs   &U/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/docx/image/tiff.pycontent_typeTiff.content_type   s     ~~    c                    R# )z:Default filename extension, always 'tiff' for TIFF images.tiff r   s   &r   default_extTiff.default_ext   s     r   c                    \         P                  V4      pVP                  pVP                  pVP                  pVP
                  pV ! W4WV4      # )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____classdictcell____classdict__s   @r   r   r      sF     
  
   
< 
<r   r   c                      a a ] tR t^%t oRtV 3R lt]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R 4       tR	 t]R
 4       tRtVtV ;t# )r   zgParses a TIFF image stream to extract the image properties found in its main
image file directory (IFD)c                8   < \         \        V `  4        Wn        R # N)superr   __init___ifd_entries)r   ifd_entries	__class__s   &&r   r4   _TiffParser.__init__)   s    k4)+'r   c                    V P                  V4      pVP                  ^4      p\        P                  W#4      pV ! V4      # )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_offsetr6   s   &&   r   r   _TiffParser.parse-   s?     ,,V4
 **1-!--jF;r   c                @    V P                  \        P                  4      # )zThe 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        yy..//r   c                @    V P                  \        P                  4      # )zThe 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    V P                   P                  \        P                  4      # )zThe 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.)r5   getr   IMAGE_LENGTHr   s   &r   r   _TiffParser.px_heightB   s!    
   $$X%:%:;;r   c                T    V P                   P                  \        P                  4      # )zThe 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.)r5   rI   r   IMAGE_WIDTHr   s   &r   r   _TiffParser.px_widthI   s!    
   $$X%9%9::r   c                l    VP                  ^ 4       VP                  ^4      pVR8X  d   \        # \        # )zReturn 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0zCmCr   c                    V P                   pW9  d   ^H# VP                  \        P                  ^4      pV^8X  d   ^H# V^8X  d   ^MRpW!,          p\	        \        WT,          4      4      # )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.
gRQ@)r5   rI   r   RESOLUTION_UNITintround)r   resolution_tagr6   resolution_unitunits_per_inchdots_per_units   &&    r   rA   _TiffParser._dpiX   sd     '', &//(*B*BAFa-2#357899r   c                :    V P                  V4      p\        W4      # )zReturn a |StreamReader| instance with wrapping `stream` and having "endian-
ness" determined by the 'MM' or 'II' indicator in the TIFF stream header.)rS   r   )r    r!   endians   && r   r:   _TiffParser._make_stream_readern   s     ##F+F++r   )r5   )r%   r&   r'   r(   r)   r4   r+   r   r*   r   r   r   r   rS   rA   r:   r,   r-   __classcell__r7   r/   s   @@r   r   r   %   s     "(     0 0
 0 0
 < < ; ; D D:, , , ,r   r   c                   \   a a ] tR t^vt oRtV 3R ltR tR t]R 4       t	RR lt
RtVtV ;t# )	r<   zyImage File Directory for a TIFF image, having mapping (dict) semantics allowing
"tag" values to be retrieved by tag code.c                8   < \         \        V `  4        Wn        R # r2   )r3   r<   r4   _entries)r   entriesr7   s   &&r   r4   _IfdEntries.__init__z   s    k4)+r   c                8    V P                   P                  V4      # )z5Provides ``in`` operator, e.g. ``tag in ifd_entries``)re   __contains__r   keys   &&r   ri   _IfdEntries.__contains__~   s    }}))#..r   c                8    V P                   P                  V4      # )zCProvides indexed access, e.g. ``tag_value = ifd_entries[tag_code]``)re   __getitem__rj   s   &&r   rn   _IfdEntries.__getitem__   s    }}((--r   c                    \        W4      pVP                  4        Uu/ uF  qDP                  VP                  bK  	  ppV ! V4      # u upi )zNReturn a new |_IfdEntries| instance parsed from `stream` starting at
`offset`.)
_IfdParseriter_entriestagvalue)r    r!   offset
ifd_parsererf   s   &&&   r   r#   _IfdEntries.from_stream   sG      /
+5+B+B+DE+Da55!''>+DE7| Fs   Ac                8    V P                   P                  W4      # )z`Return value of IFD entry having tag matching `tag_code`, or `default` if no
matching tag found.)re   rI   )r   tag_codedefaults   &&&r   rI   _IfdEntries.get   s     }}  33r   )re   r2   )r%   r&   r'   r(   r)   r4   ri   rn   r+   r#   rI   r,   r-   ra   rb   s   @@r   r<   r<   v   s7     1 /.  4 4r   r<   c                   L   a a ] tR t^t oRtV 3R ltR t]R 4       tRt	Vt
V ;t# )rq   z]Service object that knows how to extract directory entries from an Image File
Directory (IFD)c                D   < \         \        V `  4        Wn        W n        R # r2   )r3   rq   r4   _stream_rdr_offset)r   r=   ru   r7   s   &&&r   r4   _IfdParser.__init__   s    j$(*%r   c              #     "   \        V P                  4       F>  pV P                  ^,           V^,          ,           p\        V P                  V4      pVx  K@  	  R# 5i)zNGenerate an |_IfdEntry| instance corresponding to each entry in the
directory.N)range_entry_countr   _IfdEntryFactoryr   )r   idxdir_entry_offset	ifd_entrys   &   r   rr   _IfdParser.iter_entries   sL      **+C#||a/38<()9)9;KLIO ,s   AAc                L    V P                   P                  V P                  4      # )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)   r4   rr   r*   r   r,   r-   ra   rb   s   @@r   rq   rq      s-     
 9 9 9r   rq   c                   \         P                  \        \         P                  \        \         P
                  \        \         P                  \        /pV P                  V^4      pVP                  V\        4      pVP                  W4      # )zpReturn an |_IfdEntry| subclass instance containing the value of the directory
entry at `offset` in `stream_rdr`.)r   ASCII_AsciiIfdEntrySHORT_ShortIfdEntryLONG_LongIfdEntryRATIONAL_RationalIfdEntryr   rI   	_IfdEntryr#   )r=   ru   ifd_entry_classes
field_typeEntryClss   &&   r   r   r      sj     	},	 &&vq1J $$Z;H
33r   c                   v   a a ] tR t^t oRtV 3R lt]R 4       t]R 4       t]	R 4       t
]	R 4       tRtVtV ;t# )r   zkBase class for IFD entry classes.

Subclasses are differentiated by value type, e.g. ASCII, long int, etc.
c                D   < \         \        V `  4        Wn        W n        R # r2   )r3   r   r4   	_tag_code_value)r   rz   rt   r7   s   &&&r   r4   _IfdEntry.__init__   s    i')!r   c                    VP                  V^ 4      pVP                  V^4      pVP                  V^4      pV P                  WWE4      pV ! W64      # )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.
)r   r;   _parse_value)r    r=   ru   rz   value_countvalue_offsetrt   s   &&&    r   r#   _IfdEntry.from_stream   sW     ((3 **615!++FA6  [O8##r   c                    R# )zoReturn the value of this field parsed from `stream_rdr` at `offset`.

Intended to be overridden by subclasses.
zUNIMPLEMENTED FIELD TYPEr   r    r=   ru   r   r   s   &&&&&r   r   _IfdEntry._parse_value   s     *r   c                    V P                   # )z.Short int code that identifies this IFD entry.)r   r   s   &r   rs   _IfdEntry.tag   s     ~~r   c                    V P                   # )z7Value of this tag, its type being dependent on the tag.)r   r   s   &r   rt   _IfdEntry.value   s     {{r   )r   r   )r%   r&   r'   r(   r)   r4   r+   r#   r   r*   rs   rt   r,   r-   ra   rb   s   @@r   r   r      sd     

 $ $ * *     r   r   c                   4   a  ] tR t^t o Rt]R 4       tRtV tR# )r   z<IFD entry having the form of a NULL-terminated ASCII string.c                4    VP                  V^,
          V4      # )zReturn the ASCII string parsed from `stream_rdr` at `value_offset`.

The length of the string, including a terminating ' ' (NUL) character, is in
`value_count`.
)read_strr   s   &&&&&r   r   _AsciiIfdEntry._parse_value   s     "";?LAAr   r   N	r%   r&   r'   r(   r)   r+   r   r,   r-   r.   s   @r   r   r      s     FB Br   r   c                   4   a  ] tR t^t o Rt]R 4       tRtV tR# )r   z0IFD entry expressed as a short (2-byte) integer.c                8    V^8X  d   VP                  V^4      # R# )zyReturn the short int value contained in the `value_offset` field of this
entry.

Only supports single values at present.
z)Multi-value short integer NOT IMPLEMENTED)r   r   s   &&&&&r   r   _ShortIfdEntry._parse_value   s"     !((33>r   r   Nr   r.   s   @r   r   r      s     :	? 	?r   r   c                   4   a  ] tR tRt o Rt]R 4       tRtV tR# )r   i  z/IFD entry expressed as a long (4-byte) integer.c                8    V^8X  d   VP                  V^4      # R# )zxReturn the long int value contained in the `value_offset` field of this
entry.

Only supports single values at present.
z(Multi-value long integer NOT IMPLEMENTEDr;   r   s   &&&&&r   r   _LongIfdEntry._parse_value  s"     !''22=r   r   Nr   r.   s   @r   r   r     s     9	> 	>r   r   c                   4   a  ] tR tRt o Rt]R 4       tRtV tR# )r   i  z5IFD entry expressed as a numerator, denominator pair.c                j    V^8X  d,   VP                  V4      pVP                  V^4      pWV,          # R# )zReturn the rational (numerator / denominator) value at `value_offset` in
`stream_rdr` as a floating-point number.

Only supports single values at present.
z$Multi-value Rational NOT IMPLEMENTEDr   )r    r=   ru   r   r   	numeratordenominators   &&&&&  r   r   _RationalIfdEntry._parse_value  s:     !",,\:I$..|Q?K**9r   r   Nr   r.   s   @r   r   r     s     ?: :r   r   N)	constantsr   r   r   helpersr   r   r   imager	   r   r   r<   rq   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   