
    j	                    b    d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
  G d de          ZdS )	z7The proxy class for an image part, and related objects.    )annotationsN)Image)Part)EmuInchesc                       e Zd ZdZ	 dd fd
Zed             Zed             Zed             Ze	d             Z
edd            Ze	d             Zed             Z xZS )	ImagePartzlAn image part.

    Corresponds to the target part of a relationship with type RELATIONSHIP_TYPE.IMAGE.
    Npartnamestrcontent_typeblobbytesimageImage | Nonec                j    t          t          |                               |||           || _        d S N)superr	   __init___image)selfr
   r   r   r   	__class__s        Z/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/docx/parts/image.pyr   zImagePart.__init__   s2     	i'',EEE    c                Z    | j         j        }| j         j        }||z  }t          |          S )zkNative width of this image, calculated from its width in pixels and
        horizontal dots per inch (dpi).)r   px_widthhorz_dpir   )r   r   r   width_in_inchess       r   
default_cxzImagePart.default_cx   s0     :&:&"X-o&&&r   c                `    | j         j        }| j         j        }d|z  |z  }t          |          S )zkNative height of this image, calculated from its height in pixels and
        vertical dots per inch (dpi).i )r   	px_heightr   r   )r   r    r   height_in_emus       r   
default_cyzImagePart.default_cy!   s5     J(	:&*X5=!!!r   c                F    | j         | j         j        S d| j        j        z  S )a?  Filename from which this image part was originally created.

        A generic name, e.g. 'image.png', is substituted if no name is available, for
        example when the image was loaded from an unnamed stream. In that case a default
        extension is applied based on the detected MIME type of the image.
        Nzimage.%s)r   filenamer
   extr   s    r   r$   zImagePart.filename*   s'     ;";''DM---r   c                :    t          ||j        |j        |          S )zZReturn an |ImagePart| instance newly created from `image` and assigned
        `partname`.)r	   r   r   )clsr   r
   s      r   
from_imagezImagePart.from_image6   s     5#5uz5IIIr   returnr   c                Z    | j         t          j        | j                  | _         | j         S r   )r   r   	from_blobr   r&   s    r   r   zImagePart.image<   s%    ;/$)44DK{r   c                     | |||          S )zCalled by ``docx.opc.package.PartFactory`` to load an image part from a
        package being opened by ``Document(...)`` call. )r(   r
   r   r   packages        r   loadzImagePart.loadB   s     s8\4000r   c                X    t          j        | j                                                  S )z0SHA1 hash digest of the blob of this image part.)hashlibsha1_blob	hexdigestr&   s    r   r3   zImagePart.sha1H   s"     |DJ''11333r   r   )r
   r   r   r   r   r   r   r   )r*   r   )__name__
__module____qualname____doc__r   propertyr   r"   r$   classmethodr)   r   r0   r3   __classcell__)r   s   @r   r	   r	      s         TX       ' ' X' " " X" 	. 	. X	. J J [J
    X
 1 1 [1
 4 4 X4 4 4 4 4r   r	   )r9   
__future__r   r2   docx.image.imager   docx.opc.partr   docx.sharedr   r   r	   r.   r   r   <module>rA      s    = = " " " " " "  " " " " " "       # # # # # # # #?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4r   