U
    :vh	                     @   sb   d dl mZmZ d dlmZ G dd deZG dd deZG dd deZeG d	d
 d
Z	dS )    )	dataclassfield)Dictc                   @   sP   e Zd ZdZedd Zedd Zedd Zedd	 Zd
d Z	dd Z
dS )	ImageInfozInformation about an image used in the PDF document (base class).
    We subclass this to distinguish between raster and vector images.c                 C   s   | d S )zIntrinsic image widthw selfr   r   =/tmp/pip-unpacked-wheel-dvf6lv8i/fpdf/image_datastructures.pywidth	   s    zImageInfo.widthc                 C   s   | d S )zIntrinsic image heighthr   r   r   r   r
   height   s    zImageInfo.heightc                 C   s   | d S );Only available if the image has been placed on the documentrendered_widthr   r   r   r   r
   r      s    zImageInfo.rendered_widthc                 C   s   | d S )r   rendered_heightr   r   r   r   r
   r      s    zImageInfo.rendered_heightc                 C   s   dd |   D }d| dS )Nc                 S   s"   i | ]\}}||d krdn|qS ))dataZiccpZsmaskz...r   ).0kvr   r   r
   
<dictcomp>   s     z%ImageInfo.__str__.<locals>.<dictcomp>zself.__class__.__name__())items)r	   dr   r   r
   __str__   s    zImageInfo.__str__c                 C   s^   | j | j }|| |k r6|| }|}||| d 7 }n|| }|}||| d 7 }||||fS )z
        Make an image fit within a bounding box, maintaining its proportions.
        In the reduced dimension it will be centered within the available space.
           )r   r   )r	   xyr   r   ZratioZnew_wZnew_hr   r   r
   scale_inside_box#   s    zImageInfo.scale_inside_boxN)__name__
__module____qualname____doc__propertyr   r   r   r   r   r   r   r   r   r
   r      s   



r   c                   @   s   e Zd ZdZdddZdS )RasterImageInfoz9Information about a raster image used in the PDF document   c                 C   sl   |dkr*|dkr*| d | }| d | }n:|dkrH|| d  | d  }n|dkrd|| d  | d  }||fS )Nr   r   r   r   )r	   r   r   Zscaler   r   r
   size_in_document_units7   s    z&RasterImageInfo.size_in_document_unitsN)r$   )r   r   r    r!   r%   r   r   r   r
   r#   4   s   r#   c                   @   s   e Zd ZdZdS )VectorImageInfoz9Information about a vector image used in the PDF documentN)r   r   r    r!   r   r   r   r
   r&   B   s   r&   c                   @   sV   e Zd ZU eedZeeef ed< eedZ	ee
ef ed< dZeed< dd ZdS )	
ImageCache)default_factoryimagesicc_profilesAUTOimage_filterc                 C   s   | j  D ]}d|d< q
d S )Nr   usages)r)   values)r	   imgr   r   r
   reset_usagesQ   s    zImageCache.reset_usagesN)r   r   r    r   dictr)   r   str__annotations__r*   bytesintr,   r0   r   r   r   r
   r'   H   s   
r'   N)
dataclassesr   r   typingr   r1   r   r#   r&   r'   r   r   r   r
   <module>   s   /