
    Pqh	                    Z    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y)	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.
    c                >    t         t        |   |||       || _        y N)superr	   __init___image)selfpartnamecontent_typeblobimage	__class__s        Q/srv/www/ollama/chat-ollama/venv/lib/python3.12/site-packages/docx/parts/image.pyr   zImagePart.__init__   s     	i',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   s7     ::&&::&&"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!   s<     JJ((	::&&*X5=!!r   c                x    | 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.
        zimage.%s)r   filenamer   extr   s    r   r!   zImagePart.filename*   s3     ;;";;'''DMM----r   c                F    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#5#5uzz5IIr   c                z    | j                   $t        j                  | j                        | _         | j                   S r   )r   r   	from_blobr   r#   s    r   r   zImagePart.image<   s*    ;;//$))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     8\400r   c                \    t        j                  | j                        j                         S )z0SHA1 hash digest of the blob of this image part.)hashlibsha1_blob	hexdigestr#   s    r   r/   zImagePart.sha1H   s      ||DJJ'1133r   r   )r   strr   r2   r   bytesr   zImage | None)returnr   )__name__
__module____qualname____doc__r   propertyr   r   r!   classmethodr&   r   r,   r/   __classcell__)r   s   @r   r	   r	      s     TX+.6;DP ' ' " " 	. 	. J J
  
 1 1
 4 4r   r	   )r8   
__future__r   r.   docx.image.imager   docx.opc.partr   docx.sharedr   r   r	   r*   r   r   <module>r@      s#    = "  "  #?4 ?4r   