
    }f                         d dl mZmZ d dlmZ ddlmZ  G d de          Z G d de          Z	 G d	 d
e          Z
e G d d                      ZdS )    )	dataclassfield)Dict   )Alignc                       e Zd ZdZed             Zed             Zed             Zed             Zd Z	d Z
e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                     | d         S )zIntrinsic image widthw selfs    R/var/www/rtfcompare/venv/lib/python3.11/site-packages/fpdf/image_datastructures.pywidthzImageInfo.width        Cy    c                     | d         S )zIntrinsic image heighthr   r   s    r   heightzImageInfo.height   r   r   c                     | d         S );Only available if the image has been placed on the documentrendered_widthr   r   s    r   r   zImageInfo.rendered_width   s     $%%r   c                     | d         S )r   rendered_heightr   r   s    r   r   zImageInfo.rendered_height   s     %&&r   c                 J    d |                                  D             }d| dS )Nc                 &    i | ]\  }}||d v rdn|S ))datasmaskz...r   ).0kvs      r   
<dictcomp>z%ImageInfo.__str__.<locals>.<dictcomp>    s-    RRRTQQ!000aRRRr   zself.__class__.__name__())items)r   ds     r   __str__zImageInfo.__str__   s.    RRTZZ\\RRR.!....r   c                     | j         | j        z  }||z  |k     r||z  }|}|||z
  dz  z  }n||z  }|}|||z
  dz  z  }||||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   rationew_wnew_hs           r   scale_inside_boxzImageInfo.scale_inside_box#   sp    
 
T[(u9q==IEE!e)q AAIEE!e)q A!UE!!r   c                    |rt          d          t          j        |           } | t          j        k    r|j        |z
  dz  S | t          j        k    r|j        |z
  |j        z
  S | t          j        k    r|j        S t          d|            )NzSFPDF.image(): 'keep_aspect_ratio' cannot be used with an enum value provided to `x`r(   z*Unsupported 'x' value passed to .image(): )	
ValueErrorr   coerceCr   Rr_marginLl_margin)r)   r   pdfkeep_aspect_ratios       r   
x_by_alignzImageInfo.x_by_align3   s     	e   LOO<<EAI?"<<519s|++<<<IaIIJJJr   N)__name__
__module____qualname____doc__propertyr   r   r   r   r&   r.   staticmethodr9   r   r   r   r	   r	      s        I I   X   X & & X& ' ' X'/ / /" " "  K K \K K Kr   r	   c                       e Zd ZdZddZdS )RasterImageInfoz9Information about a raster image used in the PDF documentr   c                     |dk    r|dk    r| d         |z  }| d         |z  }n5|dk    r|| d         z  | d         z  }n|dk    r|| d         z  | d         z  }||fS )Nr   r   r   r   )r   r   r   scales       r   size_in_document_unitsz&RasterImageInfo.size_in_document_unitsF   sz    66a1ffS	E!AS	E!AA!VVDIS	)AA!VVDIS	)A!tr   N)r   )r:   r;   r<   r=   rD   r   r   r   rA   rA   C   s.        ??     r   rA   c                       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   rF   rF   Q   s        ????r   rF   c                       e Zd ZU  ee          Zeeef         ed<    ee          Z	ee
ef         ed<   dZeed<   d ZdS )
ImageCache)default_factoryimagesicc_profilesAUTOimage_filterc                 H    | j                                         D ]}d|d<   d S )Nr   usages)rJ   values)r   imgs     r   reset_usageszImageCache.reset_usages_   s4    ;%%'' 	 	CCMM	 	r   N)r:   r;   r<   r   dictrJ   r   str__annotations__rK   bytesintrM   rR   r   r   r   rH   rH   V   s          $eD999FDdO999%*U4%@%@%@L$ucz"@@@L#    r   rH   N)dataclassesr   r   typingr   enumsr   rS   r	   rA   rF   rH   r   r   r   <module>r[      s   ( ( ( ( ( ( ( (            9K 9K 9K 9K 9K 9K 9K 9Kx    i   @ @ @ @ @i @ @ @
 
 
 
 
 
 
 
 
 
 
r   