
    w;3h	                     L    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y)    N)Path)	add_input	get_inputc                     t        | d       | j                  dddt        d       | j                  dt        dd	
       | j                  ddd       | j                  dd       | j                  ddd       y )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    ]/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/pypdfium2/_cli/extract_images.pyattachr      s    fD!
>	   S	   c  
 _    J      c           	         | j                   j                         st        | j                         | j                  r| j                  sd| _        t        |       }t        t        t        | j                        dz               }| j                  D ]2  }||   }|j                  t        j                  f| j                        }t        |      }t        t        t        |                  }t        |      D ]  \  }}d| j                   j"                  ||dz   ||dz   fz  }	| j                   |	z  }
	 | j                  rK|j%                  | j&                        j)                         }|j+                  |
 d| j                          n(|j-                  |
| j                  | j&                         |j7                           5 y # t.        j0                  $ r t3        j4                          Y ?w xY w)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extractpdfiumPdfiumError	traceback	print_excclose)argspdf	n_pdigitsipageimages	n_idigitsjimager,   prefix	pil_images               r   mainrA   ,   s   ??!!# 11t{{
D/CCTZZ*,-IZZ 1v!!114 " 
 fS[*+	!&) 	HAu!TZZ__i1iQRSTQT$UUD__t+F&?? % 0 0 0 D K K MINNfXQt{{m#<=MM&DKK4;;MW KKM	* %% &##%&s   2A?G'G10G1)r3   pathlibr   pypdfium2.rawrawr'   pypdfium2._helpers_helpersr1   pypdfium2._cli._parsersr   r   r   rA    r   r   <module>rI      s         # 8<!r   