
    ,h
                        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	 ddl
mZmZ erddlmZ dd	lmZ  G d
 de	      Zy)z7The proxy class for an image part, and related objects.    )annotationsN)TYPE_CHECKING)Image)Part)EmuInches)
OpcPackage)PackURIc                       e Zd ZdZ	 d
	 	 	 	 	 	 	 d fdZed        Zed        Zed        Ze	dd       Z
edd       Ze	d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        R/var/www/html/Resume-Scraper/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                  }t        t	        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   introundr   )r   r    r   height_in_emus       r   
default_cyzImagePart.default_cy&   sF     JJ((	::&&E&9"4x"?@A=!!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_image;   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.imageA   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.loadG   s     8\400r   c                \    t        j                  | j                        j                         S )z0SHA1 hash digest of the blob of this image part.)hashlibsha1r   	hexdigestr(   s    r   r4   zImagePart.sha1M   s      ||DII&0022r   r   )r   r
   r   strr   bytesr   zImage | None)r   r   r   r
   )returnr   )r   r
   r   r6   r   r7   r0   r	   )__name__
__module____qualname____doc__r   propertyr   r$   r&   classmethodr+   r   r1   r4   __classcell__)r   s   @r   r   r      s     X\/2:?HT ' ' " " 	. 	. J J
  
 1 1
 3 3r   r   )r<   
__future__r   r3   typingr   docx.image.imager   docx.opc.partr   docx.sharedr   r   docx.opc.packager	   docx.opc.packurir
   r   r/   r   r   <module>rG      s/    = "    "  #+(?3 ?3r   