File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/image/__pycache__/image.cpython-310.pyc
o
$wel � @ s� d Z ddlmZ ddlZddlZddlZddlmZmZ ddl m
Z
ddlmZ ddl
mZmZmZmZ G dd � d �Zd
d� ZG dd
� d
�ZdS )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)�Self)�UnrecognizedImageError)�Emu�Inches�Length�lazypropertyc s� e Zd ZdZd4� fdd �Zed5dd
��Zedd� �Zedd� �Z edd� �Z
edd� �Zedd� �Z
ed6dd��Zed6dd��Zed6dd��Zed6dd ��Zed7d"d#��Zed7d$d%��Z &d8d9d+d,�Zed-d.� �Ze &d:d;d2d3��Z� ZS )<�ImagezgGraphical image stream such as JPEG, PNG, or GIF with properties and methods
required by ImagePart.�blob�bytes�filename�str�image_header�BaseImageHeaderc s$ t t| ��� || _|| _|| _d S �N)�superr �__init__�_blob� _filename�
_image_header)�selfr r r �� __class__� �I/home/arjun/projects/env/lib/python3.10/site-packages/docx/image/image.pyr s
zImage.__init__�returnr c C s t �|�}| �||�S )z`Return a new |Image| subclass instance parsed from the image binary contained
in `blob`.)�io�BytesIO�_from_stream)�clsr �streamr r r � from_blob s
zImage.from_blobc C s� t |t�r,|}t|d��}|�� }t�|�}W d � n1 s w Y tj�|�}n
|}|� d� |�� }d}| �
|||�S )z�Return a new |Image| subclass instance loaded from the image file identified
by `image_descriptor`, a path or file-like object.�rbNr )�
isinstancer �open�readr r �os�path�basename�seekr )r! �image_descriptorr) �fr r"