+
    iE                        R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHtHtHtHt  ! R R4      tR R	 lt ! R
 R4      tR# )zProvides objects that can characterize image streams.

That characterization is as to content type and size, as a required step in including
them in a document.
)annotationsN)IOTuple)UnrecognizedImageError)EmuInchesLengthlazypropertyc                  b  a  ] tR t^tRtR V 3R llt]R R l4       t]R R l4       t]	R 4       t
]	R	 R
 l4       t]R 4       t]	R 4       t]	R R l4       t]	R R l4       t]	R R l4       t]	R R l4       t]	R R l4       t]	R R l4       tRR R llt]R 4       t]R R R ll4       tRtV ;t# )!ImagezcGraphical image stream such as JPEG, PNG, or GIF with properties and methods
required by ImagePart.c               $    V ^8  d   QhRRRRRR/# )   blobbytesfilenamestrimage_headerBaseImageHeader )formats   "W/Users/agent/.openclaw/workspace/.venv/lib/python3.14/site-packages/docx/image/image.py__annotate__Image.__annotate__   s!     * *U *c * *    c                	P   < \         \        V `  4        Wn        W n        W0n        R # N)superr   __init___blob	_filename_image_header)selfr   r   r   	__class__s   &&&&r   r   Image.__init__   s     eT#%
!)r   c                    V ^8  d   QhRRRR/# )r   r   r   returnr   r   )r   s   "r   r   r      s     . .U .u .r   c                P    \         P                  ! V4      pV P                  W!4      # )zXReturn a new |Image| subclass instance parsed from the image binary contained
in `blob`.)ioBytesIO_from_stream)clsr   streams   && r   	from_blobImage.from_blob   s#     D!--r   c                   V ^8  d   QhRR/# )r   image_descriptorzstr | IO[bytes]r   )r   s   "r   r   r   $   s     8 8 8r   c                   \        V\        4      '       df   Tp\        VR4      ;_uu_ 4       pVP                  4       p\        P
                  ! V4      pRRR4       \        P                  P                  V4      pM%TpVP                  ^ 4       VP                  4       pRpV P                  XXV4      #   + '       g   i     Lh; i)zReturn a new |Image| subclass instance loaded from the image file identified
by `image_descriptor`, a path or file-like object.rbN)
isinstancer   openreadr'   r(   ospathbasenameseekr)   )r*   r/   r6   fr   r+   r   s   &&     r   	from_fileImage.from_file#   s     &,,#DdD!!QvvxD) " ww''-H%FKKN;;=DHh77 "!s   'B44C	c                    V P                   # )zThe bytes of the image 'file'.)r   r!   s   &r   r   
Image.blob4   s     zzr   c                   V ^8  d   QhRR/# r   r%   r   r   )r   s   "r   r   r   :   s     / /c /r   c                .    V P                   P                  # )zIMIME content type for this image, e.g. ``'image/jpeg'`` for a JPEG image.)r    content_typer=   s   &r   rB   Image.content_type9   s     !!...r   c                p    \         P                  P                  V P                  4      ^,          R,          # )zThe file extension for the image.

If an actual one is available from a load filename it is used. Otherwise a
canonical extension is assigned based on the content type. Does not contain the
leading period, e.g. 'jpg', not '.jpg'.
:   NN)r5   r6   splitextr   r=   s   &r   ext	Image.ext>   s'     ww/2266r   c                    V P                   # )zhOriginal image file name, if loaded from disk, or a generic filename if
loaded from an anonymous stream.)r   r=   s   &r   r   Image.filenameH   s     ~~r   c                   V ^8  d   QhRR/# r   r%   intr   )r   s   "r   r   r   O   s     + +# +r   c                .    V P                   P                  # z,The horizontal pixel dimension of the image.)r    px_widthr=   s   &r   rP   Image.px_widthN   s     !!***r   c                   V ^8  d   QhRR/# rL   r   )r   s   "r   r   r   T   s     , ,3 ,r   c                .    V P                   P                  # z*The vertical pixel dimension of the image.)r    	px_heightr=   s   &r   rU   Image.px_heightS   s     !!+++r   c                   V ^8  d   QhRR/# rL   r   )r   s   "r   r   r   Y        + +# +r   c                .    V P                   P                  # zwInteger dots per inch for the width of this image.

Defaults to 72 when not present in the file, as is often the case.
)r    horz_dpir=   s   &r   r[   Image.horz_dpiX        !!***r   c                   V ^8  d   QhRR/# rL   r   )r   s   "r   r   r   a   rX   r   c                .    V P                   P                  # zxInteger dots per inch for the height of this image.

Defaults to 72 when not present in the file, as is often the case.
)r    vert_dpir=   s   &r   ra   Image.vert_dpi`   r]   r   c                   V ^8  d   QhRR/# r   r%   r   r   )r   s   "r   r   r   i   s     5 5v 5r   c                N    \        V P                  V P                  ,          4      # )zuA |Length| value representing the native width of the image, calculated from
the values of `px_width` and `horz_dpi`.)r   rP   r[   r=   s   &r   widthImage.widthh   s     dmmdmm344r   c                   V ^8  d   QhRR/# rd   r   )r   s   "r   r   r   o   s     6 6 6r   c                N    \        V P                  V P                  ,          4      # )zwA |Length| value representing the native height of the image, calculated from
the values of `px_height` and `vert_dpi`.)r   rU   ra   r=   s   &r   heightImage.heightn   s     dnnt}}455r   c               $    V ^8  d   QhRRRRRR/# )r   rf   zint | Length | Nonerj   r%   zTuple[Length, Length]r   )r   s   "r   r   r   t   s$     ' '('9L'	'r   c                   Vf   Vf   V P                   V P                  3# VfH   Vf   Q h\        V4      \        V P                  4      ,          p\        V P                   V,          4      pVfB   \        V4      \        V P                   4      ,          p\        V P                  V,          4      p\	        V4      \	        V4      3# )a  (cx, cy) pair representing scaled dimensions of this image.

The native dimensions of the image are scaled by applying the following rules to
the `width` and `height` arguments.

* If both `width` and `height` are specified, the return value is (`width`,
`height`); no scaling is performed.
* If only one is specified, it is used to compute a scaling factor that is then
applied to the unspecified dimension, preserving the aspect ratio of the image.
* If both `width` and `height` are |None|, the native dimensions are returned.

The native dimensions are calculated using the dots-per-inch (dpi) value
embedded in the image, defaulting to 72 dpi if no value is specified, as is
often the case. The returned values are both |Length| objects.
)rf   rj   floatroundr   )r!   rf   rj   scaling_factors   &&& r   scaled_dimensionsImage.scaled_dimensionst   s    $ =V^::t{{**=%%%"6]U4;;-??N$**~56E>"5\E$**,==N4;;78F5z3v;&&r   c                ^    \         P                  ! V P                  4      P                  4       # )z#SHA1 hash digest of the image blob.)hashlibsha1r   	hexdigestr=   s   &r   ru   
Image.sha1   s      ||DJJ'1133r   c               (    V ^8  d   QhRRRRRRRR/# )	r   r+   	IO[bytes]r   r   r   z
str | Noner%   r   r   )r   s   "r   r   r      s2     1 11 1 	1
 
1r   c                X    \        V4      pVf   RVP                  ,          pV ! W#V4      # )z`Return an instance of the |Image| subclass corresponding to the format of the
image in `stream`.zimage.%s)_ImageHeaderFactorydefault_ext)r*   r+   r   r   r   s   &&&& r   r)   Image._from_stream   s1     +62!L$<$<<H4<00r   )r   r   r    )NNr   )__name__
__module____qualname____firstlineno____doc__r   classmethodr,   r:   propertyr   rB   r	   rG   r   rP   rU   r[   ra   rf   rj   rq   ru   r)   __static_attributes____classcell__)r"   s   @r   r   r      s0   * * . . 8 8    / / 7 7  
 + + , , + + + + 5 5
 6 6
'@ 4 4 1 1r   r   c                   V ^8  d   QhRR/# r   r+   ry   r   )r   s   "r   r   r      s     ! !	 !r   c                    ^ RI Hp R R lpV! V 4      pV F5  w  rEpV\        V4      ,           pW5V pW8X  g   K$  VP                  V 4      u # 	  \        h)zRA |BaseImageHeader| subclass instance that can parse headers of image in `stream`.)
SIGNATURESc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   )_ImageHeaderFactory.<locals>.__annotate__   s      	 r   c                F    V P                  ^ 4       V P                  ^ 4      # )    )r8   r4   )r+   s   &r   read_32$_ImageHeaderFactory.<locals>.read_32   s    A{{2r   )
docx.imager   lenfrom_streamr   )	r+   r   r   headerr*   offsetsignature_bytesendfound_bytess	   &        r   r{   r{      sZ    % V_F(2$_s?++C()??6**	 )3
 ! r   c                      ] tR t^tRtR R lt]R R l4       t]R R l4       t]R 4       t	]R	 4       t
]R
 4       t]R 4       tRtR# )r   z>Base class for image header subclasses like |Jpeg| and |Tiff|.c               (    V ^8  d   QhRRRRRRRR/# )r   rP   rM   rU   r[   ra   r   )r   s   "r   r   BaseImageHeader.__annotate__   s(     " " " " "s "r   c                	6    Wn         W n        W0n        W@n        R # r   )	_px_width
_px_height	_horz_dpi	_vert_dpi)r!   rP   rU   r[   ra   s   &&&&&r   r   BaseImageHeader.__init__   s    !#!!r   c                   V ^8  d   QhRR/# r@   r   )r   s   "r   r   r      s     ' 'c 'r   c                    Rp\        V4      h)zDAbstract property definition, must be implemented by all subclasses.zNcontent_type property must be implemented by all subclasses of BaseImageHeaderNotImplementedError)r!   msgs   & r   rB   BaseImageHeader.content_type   s     _!#&&r   c                   V ^8  d   QhRR/# r@   r   )r   s   "r   r   r      s     
 
S 
r   c                    \        R4      h)z}Default filename extension for images of this type.

An abstract property definition, must be implemented by all subclasses.
zMdefault_ext property must be implemented by all subclasses of BaseImageHeaderr   r=   s   &r   r|   BaseImageHeader.default_ext   s     "[
 	
r   c                    V P                   # rO   )r   r=   s   &r   rP   BaseImageHeader.px_width   s     ~~r   c                    V P                   # rT   )r   r=   s   &r   rU   BaseImageHeader.px_height   s     r   c                    V P                   # rZ   )r   r=   s   &r   r[   BaseImageHeader.horz_dpi        ~~r   c                    V P                   # r`   )r   r=   s   &r   ra   BaseImageHeader.vert_dpi   r   r   )r   r   r   r   N)r~   r   r   r   r   r   r   rB   r|   rP   rU   r[   ra   r   r   r   r   r   r      s    H" ' '
 
 
        r   r   )r   
__future__r   rt   r'   r5   typingr   r   docx.image.exceptionsr   docx.sharedr   r   r   r	   r   r{   r   r   r   r   <module>r      s@    #  	 	  8 9 9S1 S1l!"1 1r   