File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/parts/__pycache__/image.cpython-310.pyc
o
$we� � @ sT d Z ddlmZ ddlZddlmZ ddlmZ ddlm Z m
Z
G dd� de�ZdS ) z7The proxy class for an image part, and related objects.� )�annotationsN)�Image)�Part)�Emu�Inchesc s| e Zd ZdZ dd� fd
d�
Zedd
� �Zedd� �Zedd� �Ze dd� �Z
eddd��Ze dd� �Zedd� �Z
� ZS )� 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 s t t| ��|||� || _d S �N)�superr �__init__�_image)�selfr r
r r
�� __class__� �I/home/arjun/projects/env/lib/python3.10/site-packages/docx/parts/image.pyr s
zImagePart.__init__c C s | j j}| j j}|| }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_inchesr r r �
default_cx s zImagePart.default_cxc C s$ | j j}| j j}d| | }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_emur r r �
default_cy! s zImagePart.default_cyc C s | j dur | j jS d| jj 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.
Nzimage.%s)r �filenamer �ext�r r r r r * s
zImagePart.filenamec C s t ||j|j|�S )zZReturn an |ImagePart| instance newly created from `image` and assigned
`partname`.)r r
r )�clsr
r r r r �
from_image6 s zImagePart.from_image�returnr c C s | j d u rt�| j�| _ | j S r )r r � from_blobr r! r r r r
<