
    )i                     |    S SK r S SKrS SKJr  S SKJr  S SKJr	  S SK
JrJrJr  \ R                  " \5      rS rS rg)    N)Path)	add_input	get_inputBooleanOptionalActionc                    [        U SS9  U R                  SSS[        SS9  U R                  S[        SS	S
9  U R                  SSSS9  U R                  SSS9  U R                  SSSS9  U R                  S[        SSS9  g )NT)pagesz--output-dirz-oz-Output directory to take the extracted images)requiredtypehelpz--max-depth   zAMaximum recursion depth to consider when looking for pageobjects.)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--renderznWhen --use-bitmap is given, whether to get rendered bitmaps, taking masks and transform matrices into account.z--scale-to-originalzWhen --use-bitmap --render is given, whether to scale the image so it is rendered at its native resolution, or close to that. This should improve output quality. The default is True, but you may opt out.)r   r   r   )r   add_argumentr   intr   )parsers    ]/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/pypdfium2/_cli/extract_images.pyattachr      s    fD!
>	   R	   c  
 _     
 & ]	      c                 
   U R                   R                  5       (       d  [        U R                   5      eU R                  (       a  U R                  (       d  SU l        [        U 5      n[        [        [        U R                  5      S-   5      5      nU R                   GH1  nX   nUR                  [        R                  4U R                  S9n[        U5      n[        [        [        U5      5      5      n[        U5       H  u  pxSX#S-   XgS-   4-  n	U R                   U R                   R"                   SU	 3-  n
 U R                  (       aS  UR%                  U R&                  U R(                  S9R+                  5       nUR-                  U
 SU R                   35        OUR/                  XR                  S9   UR9                  5         M     GM4     g ! [0        R2                   a    [4        R6                  " 5          NEf = f)	Npng   )filter	max_depthz	%0*d_%0*d_)renderscale_to_original.)	fb_format)
output_diris_dirNotADirectoryError
use_bitmapformatr   lenstrmaxr   get_objectspdfium_cFPDF_PAGEOBJ_IMAGEr   list	enumerateinputstem
get_bitmapr   r   to_pilsaveextractpdfiumPdfiumError	traceback	print_excclose)argspdf	n_pdigitsipageimages	n_idigitsjimagetagprefix	pil_images               r   mainrD   7   s   ??!!## 11t{{
D/CCTZZ*,-IZZv!!114 " 
 fS[*+	!&)HAaCaC @@C__$**//):!C5'AAF&?? % 0 0W[WmWm 0 n u u wINNfXQt{{m#<=MM&KKM@ KKM * , %% &##%&s   >A#G"G)HH)loggingr5   pathlibr   pypdfium2.rawrawr)   pypdfium2._helpers_helpersr3   pypdfium2._cli._parsersr   r   r   	getLogger__name__loggerr   rD    r   r   <module>rP      s=         # 
 
		8	$!H"r   