
    TAi                        % S r SSKJ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  SSKJr  \R                  " \5      r\" 5       rS	\S
'   \S 5       r\S 5       r\S 5       r\S 5       rg)zIBuilt-in plugin to implement PDF page rasterization and PDF/A production.    )annotationsN)Version)hookimpl)ghostscript)MissingDependencyError)check_external_programzfrozenset[Version]BLACKLISTED_GS_VERSIONSc           
         U R                  SS5      nUR                  SS[        S[        R                  SSS9  UR                  S	/ S
QSSS9  g )NGhostscriptzAdvanced control of Ghostscriptz--color-conversion-strategystoreSTRATEGYLeaveColorUnchangedz)Set Ghostscript color conversion strategy)actiontypemetavarchoicesdefaulthelpz--pdfa-image-compression)autojpeglosslessr   a  Specify how to compress images in the output PDF/A. 'auto' lets OCRmyPDF decide.  'jpeg' changes all grayscale and color images to JPEG compression.  'lossless' uses PNG-style lossless compression for all images.  Monochrome images are always compressed using a lossless codec.  Compression settings are applied to all pages, including those for which OCR was skipped.  Not supported for --output-type=pdf ; that setting preserves the original compression of all images.)r   r   r   )add_argument_groupadd_argumentstrr   COLOR_CONVERSION_STRATEGIES)parsergss     `/var/www/html/land-ocr/venv/lib/python3.13/site-packages/ocrmypdf/builtin_plugins/ghostscript.pyadd_optionsr      sb    		"	"=2S	TBOO%77%8   OO",<	      c                b   [        SS[        R                  SS9  [        R                  " 5       nU[        ;   a  [	        SU S35      e[        S5      Us=::  a  [        S5      :  a4  O  O1U R                  (       d  U R                  (       a  [	        S	U S
35      eU R                  S:X  a  SU l        U R                  [        R                  ;  a  [        SU R                   35      eU R                  S:w  a7  U R                  R                  S5      (       d  [        R                  S5        ggg)z1Check that the options are valid for this plugin.r   r   z9.54)programpackageversion_checkerneed_versionzGhostscript zV contains serious regressions and is not supported. Please upgrade to a newer version.z10.0.0z10.02.1z2Ghostscript 10.0.0 through 10.02.0 (your version: z) contain serious regressions that corrupt PDFs with existing text, such as those processed using --skip-text or --redo-ocr. Please upgrade to a newer version, or use --output-type pdf to avoid Ghostscript, or use --force-ocr to discard existing text.pdfazpdfa-2z#Invalid color conversion strategy: r   zi--pdfa-image-compression argument only applies when --output-type is one of 'pdfa', 'pdfa-1', or 'pdfa-2'N)r   r   versionr	   r   r   	skip_textredo_ocroutput_typecolor_conversion_strategyr   
ValueErrorpdfa_image_compression
startswithlogwarning)options
gs_versions     r   check_optionsr3   2   s/    #++	 $$&J,,$:, '< <
 	
 xJ;);;W--$@ M8 8
 	
 f$&((0W0WW1'2S2S1TU
 	
 %%/8K8K8V8V9 9 	D	
9/r    c	                >    [         R                  " U UUUUUUUUS9	  U$ )z8Rasterize a single page of a PDF file using Ghostscript.)raster_device
raster_dpipagenopage_dpirotationfilter_vectorstop_on_error)r   rasterize_pdf)	
input_fileoutput_filer5   r6   r7   r8   r9   r:   stop_on_soft_errors	            r   rasterize_pdf_pager@   \   s5     ##(
 r    c                    [         R                  " U/U QUUR                  R                  UR                  R                  UUUUS9  U$ )z?Generate a PDF/A from the list of PDF pages and PDF/A metadata.)	pdf_pagesr>   compressionr+   pdf_version	pdfa_partprogressbar_classr;   )r   generate_pdfar1   r-   r+   )rB   pdfmarkr>   contextrD   rE   rF   r?   s           r   rG   rG   w   sN     'Y'OO::")//"K"K+(	 r    )__doc__
__future__r   loggingpackaging.versionr   ocrmypdfr   ocrmypdf._execr   ocrmypdf.exceptionsr   ocrmypdf.subprocessr   	getLogger__name__r/   	frozensetr	   __annotations__r   r3   r@   rG    r    r   <module>rW      s    P "  %  & 6 6! /8k + 9 
 
4 
&
 
&
R 
 
4 
 
r    