o
    j                     @   s8   d dl mZ d dlmZ d dlmZ dd Zdd ZdS )    )PathN)Lazyc                 C   s:   | j dddtd | j dddtdd	 | j d
ddd d S )Nimages+zInput images)nargshelptypez--outputz-oTzTarget path for the new PDF)requiredr   r   z--inline
store_truez9If JPEG, whether to use PDFium's inline loading function.)actionr   )add_argumentr   )parser r   W/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/pypdfium2_cli/imgtopdf.pyattach
   s"   
r   c           	      C   s   t j }| jD ]Y}t j|}|j dv r |j|| jd nt	j
|}t j|}|  || |  | \}}|t  || |||}|| |  |  |  q|| j |  d S )N)z.jpgz.jpeg)inline)pdfiumZPdfDocumentnewr   ZPdfImagesuffixlowerZ	load_jpegr   r   Z	PIL_ImageopenZ	PdfBitmapZfrom_pilcloseZ
set_bitmapZget_px_sizeZ
set_matrixZ	PdfMatrixscaleZnew_pageZ
insert_objZgen_contentsaveoutput)	argsZpdffpZ	image_objZ	pil_imageZbitmapwhpager   r   r   main   s&   




r    )	pathlibr   Zpypdfium2._helpersZ_helpersr   Zpypdfium2._lazyr   r   r    r   r   r   r   <module>   s
   