
    Ng	                     N    d dl Z d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d Zd ZdS )    N)Path)	add_input	get_inputc                 0   t          | d           |                     dddt          d           |                     dt          dd	
           |                     ddd           |                     dd           |                     ddd           d S )NT)pagesz--output-dirz-oz-Output directory to take the extracted images)requiredtypehelpz--max-depth   zBMaximum recursion depth to consider when looking for page objects.)r	   defaultr
   z--use-bitmap
store_truezREnforce the use of bitmaps rather than attempting a smart extraction of the image.)actionr
   z--formatzNImage format to use when saving bitmaps. (Fallback if doing smart extraction.))r
   z--renderzxWhether to get rendered bitmaps, taking masks and transform matrices into account. (Fallback if doing smart extraction.))r   add_argumentr   int)parsers    Y/var/www/html/ai-engine/env/lib/python3.11/site-packages/pypdfium2/_cli/extract_images.pyattachr      s    fD!!!!
>	     S	     c    
 _      J          c           	         | j                                         st          | j                   | j        r| j        sd| _        t          |           }t          t          t          | j	                  dz                       }| j	        D ]h}||         }|
                    t          j        f| j                  }t          |          }t          t          t          |                              }t          |          D ]\  }}d| j        j        ||dz   ||dz   fz  }	| j         |	z  }
	 | j        r^|                    | j                                                  }|                    |
                    d| j        z                        n"|                    |
| j        | j                   n(# t0          j        $ r t5          j                     Y nw xY w|                                 jd S )Npng   )filter	max_depthz%s_%0*d_%0*d)render.)	fb_format	fb_render)
output_diris_dirNotADirectoryError
use_bitmapformatr   lenstrmaxr   get_objectspdfium_cFPDF_PAGEOBJ_IMAGEr   list	enumerateinputstem
get_bitmapr   to_pilsavewith_suffixextractpdfiumPdfiumError	traceback	print_excclose)argspdf	n_pdigitsipageimages	n_idigitsjimager,   prefix	pil_images               r   mainrB   ,   s   ?!!## 2 111 t{ 
D//CCTZ*,,--IZ  1v!!14 " 
 
 fS[[**++	!&)) 	 	HAu!TZ_i1iQRSTQT$UUD_t+F&? X % 0 0 0 D D K K M MINNF$6$6s4;$G$GIIIIMM&DK4;MWWW% & & &#%%%%%&KKMMMM	 s   -BF55"GG)r4   pathlibr   pypdfium2.rawrawr'   pypdfium2._helpers_helpersr2   pypdfium2._cli._parsersr   r   r   rB    r   r   <module>rJ      s                          # # # # # # 8 8 8 8 8 8 8 8  <! ! ! ! !r   