ó
    ‰*£hE  ã                  ó’   • S r SSKJr  SSKrSSKrSSKrSSKJrJr  SSK	J
r
  SSKJrJrJrJr   " S S5      rSS	 jr " S
 S5      rg)z¡Provides 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                  óf  ^ • \ rS rSrSrSU 4S jjr\SS j5       r\SS j5       r\	S 5       r
\	SS j5       r\S 5       r\	S	 5       r\	SS
 j5       r\	SS j5       r\	SS j5       r\	SS j5       r\	SS j5       r\	SS j5       r S     SS jjr\S 5       r\ S       SS jj5       rSrU =r$ )ÚImageé   zcGraphical image stream such as JPEG, PNG, or GIF with properties and methods
required by ImagePart.c                óN   >• [         [        U ]  5         Xl        X l        X0l        g ©N)Úsuperr   Ú__init__Ú_blobÚ	_filenameÚ_image_header)ÚselfÚblobÚfilenameÚimage_headerÚ	__class__s       €ÚM/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docx/image/image.pyr   ÚImage.__init__   s    ø€ ÜŒe�TÑ#Ô%ØŒ
Ø!ŒØ)Õó    c                óP   • [         R                  " U5      nU R                  X!5      $ )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                óx  • [        U[        5      (       a]  Un[        US5       nUR                  5       n[        R
                  " U5      nSSS5        [        R                  R                  U5      nO%UnUR                  S5        UR                  5       nSnU R                  WWU5      $ ! , (       d  f       Nf= f)zReturn a new |Image| subclass instance loaded from the image file identified
by `image_descriptor`, a path or file-like object.ÚrbNr   )Ú
isinstanceÚstrÚopenÚreadr   r   ÚosÚpathÚbasenameÚseekr    )r!   Úimage_descriptorr,   Úfr   r"   r   s          r   Ú	from_fileÚImage.from_file#   s•   € ô Ð&¬×,Ñ,Ø#ˆDÜ�d˜DÔ! QØ—v‘v“x�ÜŸš DÓ)�÷ "ô —w‘w×'Ñ'¨Ó-‰Hà%ˆFØ�K‰K˜ŒNØ—;‘;“=ˆDØˆHØ×Ñ ¨¨hÓ7Ð7÷ "Õ!ús   ¤'B+Â+
B9c                ó   • U R                   $ )zThe bytes of the image 'file'.)r   ©r   s    r   r   Ú
Image.blob4   s   € ð �z‰zÐr   c                ó.   • U R                   R                  $ )zIMIME content type for this image, e.g. ``'image/jpeg'`` for a JPEG image.)r   Úcontent_typer4   s    r   r7   ÚImage.content_type9   s   € ð ×!Ñ!×.Ñ.Ð.r   c                ó`   • [         R                  R                  U R                  5      S   SS $ )zæThe 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'.
é   N)r+   r,   Úsplitextr   r4   s    r   ÚextÚ	Image.ext>   s)   € ô �w‰w×Ñ §¡Ó/°Ñ2°1°2Ð6Ð6r   c                ó   • U R                   $ )zhOriginal image file name, if loaded from disk, or a generic filename if
loaded from an anonymous stream.)r   r4   s    r   r   ÚImage.filenameH   s   € ð �~‰~Ðr   c                ó.   • U R                   R                  $ ©z,The horizontal pixel dimension of the image.)r   Úpx_widthr4   s    r   rB   ÚImage.px_widthN   s   € ð ×!Ñ!×*Ñ*Ð*r   c                ó.   • U R                   R                  $ ©z*The vertical pixel dimension of the image.)r   Ú	px_heightr4   s    r   rF   ÚImage.px_heightS   s   € ð ×!Ñ!×+Ñ+Ð+r   c                ó.   • U R                   R                  $ ©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_dpir4   s    r   rJ   ÚImage.horz_dpiX   ó   € ð ×!Ñ!×*Ñ*Ð*r   c                ó.   • U R                   R                  $ ©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_dpir4   s    r   rO   ÚImage.vert_dpi`   rL   r   c                óF   • [        U R                  U R                  -  5      $ )zuA |Length| value representing the native width of the image, calculated from
the values of `px_width` and `horz_dpi`.)r   rB   rJ   r4   s    r   ÚwidthÚImage.widthh   s   € ô �d—m‘m d§m¡mÑ3Ó4Ð4r   c                óF   • [        U R                  U R                  -  5      $ )zwA |Length| value representing the native height of the image, calculated from
the values of `px_height` and `vert_dpi`.)r   rF   rO   r4   s    r   ÚheightÚImage.heightn   s   € ô �d—n‘n t§}¡}Ñ4Ó5Ð5r   c                ód  • Uc  Uc  U R                   U R                  4$ Uc>  Uc   e[        U5      [        U R                  5      -  n[        U R                   U-  5      nUc9  [        U5      [        U R                   5      -  n[        U R                  U-  5      n[	        U5      [	        U5      4$ )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.
)rR   rU   ÚfloatÚroundr   )r   rR   rU   Úscaling_factors       r   Úscaled_dimensionsÚImage.scaled_dimensionst   s�   € ð$ ‰=˜V™^Ø—:‘:˜tŸ{™{Ð*Ð*à‰=ØÑ%Ð%Ð%Ü" 6›]¬U°4·;±;Ó-?Ñ?ˆNÜ˜$Ÿ*™* ~Ñ5Ó6ˆEà‰>Ü" 5›\¬E°$·*±*Ó,=Ñ=ˆNÜ˜4Ÿ;™;¨Ñ7Ó8ˆFä�5‹zœ3˜v›;Ð&Ð&r   c                ó^   • [         R                  " U R                  5      R                  5       $ )z#SHA1 hash digest of the image blob.)ÚhashlibÚsha1r   Ú	hexdigestr4   s    r   r_   Ú
Image.sha1”   s    € ô �|Š|˜DŸJ™JÓ'×1Ñ1Ó3Ð3r   c                óN   • [        U5      nUc  SUR                  -  nU " X#U5      $ )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   )r   Úbytesr   r(   r   ÚBaseImageHeader)r   rf   Úreturnr   )r/   zstr | IO[bytes]©rh   r(   )rh   Úint)rh   r   )NN)rR   úint | Length | NonerU   rk   rh   zTuple[Length, Length]r   )r"   ú	IO[bytes]r   rf   r   z
str | Nonerh   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úclassmethodr#   r1   Úpropertyr   r7   r
   r<   r   rB   rF   rJ   rO   rR   rU   r[   r_   r    Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      su  ø† ñ÷*ð ó.ó ð.ð ó8ó ð8ð  ñó ðð ó/ó ð/ð ñ7ó ð7ð ñó ðð
 ó+ó ð+ð ó,ó ð,ð ó+ó ð+ð ó+ó ð+ð ó5ó ð5ð
 ó6ó ð6ð PTð'Ø(ð'Ø9Lð'à	õ'ð@ ñ4ó ð4ð ð
  $ð	1àð1ð ð1ð ð	1ð
 
ô1ó ö1r   r   c                ó    • SSK Jn  SS jnU" U 5      nU H0  u  pEnU[        U5      -   nX5U nX†:X  d  M  UR                  U 5      s  $    [        e)zRA |BaseImageHeader| subclass instance that can parse headers of image in `stream`.r   )Ú
SIGNATURESc                óF   • U R                  S5        U R                  S5      $ )Nr   é    )r.   r*   )r"   s    r   Úread_32Ú$_ImageHeaderFactory.<locals>.read_32¬   s   € Ø�‰�AŒØ�{‰{˜2‹Ðr   ©r"   rl   )Ú
docx.imagerw   ÚlenÚfrom_streamr   )	r"   rw   rz   Úheaderr!   ÚoffsetÚsignature_bytesÚendÚfound_bytess	            r   rc   rc   ¨   sZ   € å%ôñ �V‹_€FÛ(2Ñ$ˆ�_Ø”s˜?Ó+Ñ+ˆØ CÐ(ˆØÕ)Ø—?‘? 6Ó*Ò*ñ	 )3ô
 !Ð r   c                  óŠ   • \ rS rSrSrSS jr\SS j5       r\SS j5       r\S 5       r	\S 5       r
\S 5       r\S	 5       rS
rg)rg   é¹   z>Base class for image header subclasses like |Jpeg| and |Tiff|.c                ó4   • Xl         X l        X0l        X@l        g r   )Ú	_px_widthÚ
_px_heightÚ	_horz_dpiÚ	_vert_dpi)r   rB   rF   rJ   rO   s        r   r   ÚBaseImageHeader.__init__¼   s   € Ø!ŒØ#ŒØ!ŒØ!�r   c                ó   • Sn[        U5      e)zDAbstract property definition, must be implemented by all subclasses.zNcontent_type property must be implemented by all subclasses of BaseImageHeader©ÚNotImplementedError)r   Úmsgs     r   r7   ÚBaseImageHeader.content_typeÂ   s   € ð _ˆÜ! #Ó&Ð&r   c                ó   • [        S5      e)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Ž   r4   s    r   rd   ÚBaseImageHeader.default_extÈ   s   € ô "Ø[ó
ð 	
r   c                ó   • U R                   $ rA   )rˆ   r4   s    r   rB   ÚBaseImageHeader.px_widthÒ   s   € ð �~‰~Ðr   c                ó   • U R                   $ rE   )r‰   r4   s    r   rF   ÚBaseImageHeader.px_height×   s   € ð �‰Ðr   c                ó   • U R                   $ rI   )rŠ   r4   s    r   rJ   ÚBaseImageHeader.horz_dpiÜ   ó   € ð �~‰~Ðr   c                ó   • U R                   $ rN   )r‹   r4   s    r   rO   ÚBaseImageHeader.vert_dpiä   rš   r   )rŠ   r‰   rˆ   r‹   N)rB   rj   rF   rj   rJ   rj   rO   rj   ri   )rm   rn   ro   rp   rq   r   rs   r7   rd   rB   rF   rJ   rO   rt   © r   r   rg   rg   ¹   s‚   † ÙHô"ð ó'ó ð'ð
 ó
ó ð
ð ñó ðð ñó ðð ñó ðð ñó ór   rg   r|   )rq   Ú
__future__r   r^   r   r+   Útypingr   r   Údocx.image.exceptionsr   Údocx.sharedr   r   r	   r
   r   rc   rg   r�   r   r   Ú<module>r¢      s@   ðñõ #ã Û 	Û 	ß å 8ß 9Ó 9÷S1ñ S1ôl!÷"1ò 1r   