HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/__pycache__/img2pdf.cpython-38.pyc
U

V3\Li�@sBddlZddlZddlZddlZddlmZmZddlmZddl	m	Z	ddl
mZddlm
Z
ddlmZddlZddlZejddkZd	Zd
Zddd
dddddddd�
Zddddddddddd�
Ze
d d!�Ze
d"d#�Ze
d$d%�Ze
d&d'�Ze
d(d)�Ze
d*d+�Ze
d,d-�Ze
d.d/�Ze
d0d1�Z e
d2d3�Z!dd4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�dd�d�d�d�d�d�d�d�d�d�d�d�d��d�d�d�d�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�gZ"G�d2�d3��d3e#�Z$G�d4�d5��d5e#�Z%G�d6�d7��d7e#�Z&G�d8�d9��d9e#�Z'G�d:�d;��d;e#�Z(�d<�d=�Z)�d��d>�d?�Z*G�d@�dA��dAe+�Z,G�dB�dC��dC�Z-e-�Z-G�dD�dE��dEe.�Z/G�dF�dG��dGe0�Z1G�dH�dI��dI�Z2e�r�G�dJ�dK��dK�Z3nG�dL�dK��dKe+�Z3G�dM�dN��dNe+�Z4�d��dO�dP�Z5�dQ�dR�Z6�dS�dT�Z7�dU�dV�Z8�d��dX�dY�Z9�dZ�d[�Z:�d\�d]�Z;�d^�d_�Z<�d`�da�Z=�d��db�dc�Z>�dd�de�Z?�df�dg�Z@�dh�di�ZA�dj�dk�ZB�dl�dm�ZC�dn�do�ZD�dp�dq�ZE�dr�ds�ZF�dt�du�ZG�dv�dw�ZH�dx�dy�ZI�dz�d{�ZJ�d|�d}�ZK�d~�d�ZL�d��d��ZM�d��d��ZNejOf�d��d��ZPeQ�d�k�r>eP�dS(��N)�Image�TiffImagePlugin)�TAGS)�datetime)�parsejp2)�Enum)�BytesIO�z0.3.3gX@z
8.5inx11inZ841mmx1189mmZ594mmx841mmZ420mmx594mmZ297mmx420mmZ210mmx297mmZ148mmx210mmZ105mmx148mmz
8.5inx14inZ	11inx17in)
ZletterZa0Za1Za2Za3Za4Za5Za6ZlegalZtabloidZLetterZA0ZA1ZA2ZA3ZA4ZA5ZA6ZLegalZTabloid�FitModezinto fill exact shrink enlarge�PageOrientationzportrait landscape�
Colorspacez RGB L 1 CMYK CMYK;I RGBA P other�ImageFormatz(JPEG JPEG2000 CCITTGroup4 PNG TIFF other�PageModeznone outlines thumbs�
PageLayoutz-single onecolumn twocolumnright twocolumnleft�
Magnificationzfit fith fitbh�ImgSizezabs perc dpi�Unitz
pt cm mm inch�ImgUnitzpt cm mm inch perc dpi��@�� ��`�����P���0��p�����H���(��h�����X���8��x����D���$��d�����T���4��t�����L���,��l�����\���<��|����B���"��b�����R���2��r���
��J���*��j�����Z���:��z����F���&��f�����V���6��v����N���.��n�����^���>��~����A��!��a�����Q���1��q���	��I���)��i�����Y���9��y����E���%��e�����U���5��u��
��M���-��m�����]���=��}���C���#��c�����S���3��s�����K���+��k�����[���;��{����G���'��g�����W���7��w����O���/��o�����_���?���c@seZdZdS)�NegativeDimensionErrorN��__name__�
__module__�__qualname__�rr�)/usr/lib/python3/dist-packages/img2pdf.pyrZsrc@seZdZdS)�UnsupportedColorspaceErrorNrrrrrr^src@seZdZdS)�ImageOpenErrorNrrrrrrbsrc@seZdZdS)�JpegColorspaceErrorNrrrrrrfsrc@seZdZdS)�PdfTooLargeErrorNrrrrrrjsrcCs|S�Nr)�stringrrr�my_convert_loadosrcsPt|�tkrHdd��fdd�t|���D��dd�dddSt|�tkr`t|���St|�tkr�t|�|kr�t	t|��Sd	|�
d
���Sn�t|t�r�t
|d�r�d|j��St	|j��Sn�t|�tks�t|t��rt|�tk�rt|�tk	�rtd
|��|St|t��r8dd��fdd�|D��dStdt|�|f��dS)Ns<<
�
cs2g|]*\}}d�d|dt|�d��qS)r3� r���parse)�.0�k�v��indentrr�
<listcomp>xs�zparse.<locals>.<listcomp>r3r�r!s>>z%0.4f�0�
identifierz%d 0 Rz3parse must be passed a bytes object in py3. Got: %ss[ csg|]}t|���qSrr"�r$�cr'rrr)�ss ]z%cannot handle type %s with content %s)�type�dict�join�sorted�items�int�str�encode�floatr#�rstrip�
isinstance�	MyPdfDict�hasattrr+�content�bytes�	TypeError�list)Zcontr(rr'rr#ssD

�����	��

� r#c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r9cOs�t�|_|r,t|�dkr |d}|j�|�d|_|��D]B\}}|dkrb||_t|�|jtj<q:|dkrlq:||jtt|�<q:dS)Nr�r�stream�indirect)	r/r;�len�updater?r2�	MyPdfNameZLength�getattr)�self�args�kw�key�valuerrr�__init__�szMyPdfDict.__init__cCsP|jdk	r0d|j��t|j�d|jdSd|j��t|j�dSdS)Nz	%d 0 obj
s
stream
s
endstream
endobj
s
endobj
)r?r+r5r#r;)rErrr�tostring�s"
�����	���zMyPdfDict.tostringcCs||j|<dSr�r;)rErHrIrrr�__setitem__�szMyPdfDict.__setitem__cCs
|j|SrrL)rErHrrr�__getitem__�szMyPdfDict.__getitem__N)rrrrJrKrMrNrrrrr9�sr9c@seZdZdd�ZdS)rCcCsd|�d�S)N�/�ascii�r5)rE�namerrr�__getattr__�szMyPdfName.__getattr__N)rrrrSrrrrrC�srCc@seZdZdd�ZdS)�MyPdfObjectcCst�||�d��S)NrP)r<�__new__r5)�clsrrrrrU�szMyPdfObject.__new__N)rrrrUrrrrrT�srTc@seZdZdS)�
MyPdfArrayNrrrrrrW�srWc@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�MyPdfWriter�1.3cCs:g|_ttjgdd�|_t|jtjd�|_||_g|_dS)Nr)�TypeZKidsZCount)�PagesrZ)	�objectsr9rCr[�pagesZCatalog�catalog�version�	pagearray)rEr_rrrrJ�s
zMyPdfWriter.__init__cCs$t|j�d}||_|j�|�dS)Nr�)rAr\r+�append)rE�objZnewidrrr�addobj�szMyPdfWriter.addobjc
Cst�}d|j�d�}|d7}|�|�t|�}|�d�|jD]4}|�d|���|��}|�|�|t|�7}q@|}|�d�|�dt|����|D]}	|�|	�q�|�d�|�tt|�||j	d	��d
�|�d�|�d|���|�d
�dS)Nz	%%PDF-%s
rPs%����
s0000000000 65535 f 
z%010d 00000 n 
sxref
z0 %d
strailer
)s/Sizes/Infos/Rootr s
startxref
z%d
s%%EOF
)
r>r_r5�writerArar\rKr#r^)
rE�infor?Z	xreftableZ	pdfheader�pos�or;Z
xrefoffset�xrrr�tostream�s4





��

zMyPdfWriter.tostreamcCsJ|j|d<|j�|�|jjd�|�|jjdd7<|�|�dS)Ns/Parents/Kidss/Countr�)r]r`rar;rc)rE�pagerrr�addpage%s

zMyPdfWriter.addpageN)rY)rrrrJrcrirkrrrrrX�s
	BrXc@seZdZeddd��ZdS)�MyPdfStringFcCs�|r dd�dd�|D��dSz|�d�}Wn"tk
rPd|�d�}YnX|�d	d
�}|�dd�}|�d
d�}d|d
SdS)N�< r!css|]}d|�d�VqdS�z%06xrPNrQr,rrr�	<genexpr>5s�%MyPdfString.encode.<locals>.<genexpr>� >rPs��z	utf-16-be�\�\\�(�\(�)�\))r0r5�UnicodeEncodeError�replace�rVr�hextyperrrr50s����MyPdfString.encodeN)F�rrr�classmethodr5rrrrrl/srlc@seZdZeddd��ZdS)rlFcCsT|r dd�dd�|D��dS|�dd�}|�dd	�}|�d
d�}d|d
SdS)Nrmr!css|]}d|�d�VqdSrnrQr,rrrroOsrprqrrrsrtrurvrw)r0ryrzrrrr5Js���r|N)Fr}rrrrrlIsc@s0eZdZddd�Zddd	�Zd
d�Zdd
�ZdS)�pdfdocrYNFTcCs4|rTz"ddlm}m}m}m}d|_Wqjtk
rPt}t}t	}t
}d|_YqjXnt}t}t	}t
}d|_t��}|dd�|_
dd�}|dk	r�|�|�|j
|j<|dk	r�|�|�|j
|j<|dk	r�|�|�|j
|j<|dk	r�|dkr�|�|�|j
|j<|dk	�r|�d	||��|j
|j<n |
�s<|�d	||��|j
|j<|dk	�rb|�d	||��|j
|j<n |
�s�|�d	||��|j
|j<|dk	�r�|�|�|j
|j<|	dk	�r�|�d
�|	��|j
|j<|�|_||j_|j�s|j�|j
�|j�|jj�|j�|jj�||_||_|
|_||_ ||_!||_"||_#dS)Nr)�	PdfWriter�PdfDict�PdfName�	PdfStringTF�r@cSs
|�d�S)Nz
%Y%m%d%H%M%SZ)�strftime)Zdtrrr�datetime_to_pdfdate�sz,pdfdoc.__init__.<locals>.datetime_to_pdfdate�zD:�,)$�pdfrwr�r�r�r��
with_pdfrw�ImportErrorrXr9rCrlr�nowrer5ZTitleZAuthorZCreatorZProducerZCreationDateZModDateZSubjectr0ZKeywords�writerr_rcr^r]�panes�initial_page�
magnification�page_layout�
fit_window�
center_window�
fullscreen)rEr_�title�author�creator�producer�creationdate�moddate�subject�keywords�nodater�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrJ[sv


�
�

�
�

zpdfdoc.__init__rcCsJ|jr,ddlm}m}m}m}ddlm}nt}t	}t
}t}t}|t
dksV|t
jkr^|j}nz|t
jkrp|j}nh|t
jks�|t
dkr�|j}nJ|t
jkr�|jr�td��|j|jt|
�d|j|
dd	�g}ntd
|j��|tjkr�|j}n8|tjk�r|j}d|j _!n|tj"k�r|j#g}n|j$}|||�d�}|j%||j&<|j'||j(<|||j)<|||j*<|||j+<|||j,<|||j-<|t
dk�r�d
dd
dd
dd
dg||j.<|tj"k�r|�}d||j/<|�r�|d�||j0<n|d�||j0<|||j1<|||j2<|g||j3<nh|tj4k�rl|�}d||j5<|t
jt
dt
jfk�rDd||j6<n
d||j6<|||j1<|||j-<|||j3<d||||	f�d�}|||�d�}|||d�d�}|dd�}|j7||j&<dd|
|g||j8<|||j9<|||j:<|dk�r�|||j;<|dk	�r|j j!dk�rd|j _!|||j<<|j �=|�|j�sF|j �>|�|j �>|�dS)Nr)r�r��	PdfObjectr�)�convert_load�1�CMYK;IzWpdfrw does not support hex strings for palette image input, re-run with --without-pdfrwr�T)r{zunsupported color space: %sz1.5)r?g�?g���Zfalse�truerr	z*q
%0.4f 0 0 %0.4f %0.4f %0.4f cm
/Im0 Do
QrP)ZIm0)�XObjectr�z1.6)?r�r�r�r�r�r�Zpdfrw.py23_diffsr�r9rCrTrlrr�LZ
DeviceGray�RGBZ	DeviceRGB�CMYKZ
DeviceCMYK�P�	ExceptionZIndexedrAr5rrRr
�JPEGZ	DCTDecode�JPEG2000Z	JPXDecoder�r_�CCITTGroup4ZCCITTFaxDecodeZFlateDecoder�rZrZSubtypeZFilterZWidthZHeightZ
ColorSpaceZBitsPerComponentZDecode�KZBlackIs1ZColumnsZRowsZDecodeParms�PNGZ	PredictorZColorsZPage�MediaBoxZ	Resources�ContentsZRotateZUserUnitrkrc)rE�color�
imgwidthpx�imgheightpx�	imgformat�imgdata�imgwidthpdf�imgheightpdf�imgxpdf�imgypdf�	pagewidth�
pageheight�userunit�palette�inverted�depth�rotater�r�r�r�r��
colorspaceZofilterZimageZdecodeparms�textr;Z	resourcesrjrrr�
add_imagepage�s�

�
�
















���






zpdfdoc.add_imagepagecCst�}|�|�|��Sr)rri�getvalue)rEr?rrrrK4s
zpdfdoc.tostringcCs<|jr ddlm}m}m}m}nt}t}t}t	}|d�}|d�}|jrR|j
jj}n|j
j
}|jsv|jsv|jsv|jdk	r�|�||j<|jr�|j||j|j<|jtjkr�|j||j|j<|j||j<nN|jtjkr�|j||j|j<|j||j<n"|jtjdfk�rntd|j��|j�r,|||j|j<|j�rD|||j|j<|j�rX|j||j<|j
jd}	|j dk	�r�|j
j|j d}	||	|j!||dg�||j"<|j#t$j%k�r�||	|j&g�||j"<n�|j#t$j'k�r�|	|j(d}
||	|j)|
g�||j"<n�|j#t$j*k�r2t+|	|j,j-�.�d�}||	|j/|g�||j"<nHt0|j#t+��r^||	|j!|||j#g�||j"<n|j#dk�rlntd	|j#��|j1t2j3k�r�|j4||j2<np|j1t2j5k�r�|j6||j2<nT|j1t2j7k�r�|j8||j2<n8|j1t2j9k�r�|j:||j2<n|j1dk�r�ntd
|j1��|j�r(|j;|j
j_<|j
�=|�n|j
�>|j;|�dS)Nr)r�r��PdfArrayr�Znullr�zunknown page mode: %sr�rSr3zunknown magnification: %szunknown page layout: %s)?r�r�r�r�r�r�r9rCrTrWr�ZtrailerZRootr^r�r�r�r�ZViewerPreferencesZUseNoneZNonFullScreenPageModerZthumbsZ	UseThumbsZoutlinesZUseOutlinesZnone�
ValueErrorZ	FitWindowZCenterWindowZ
FullScreenr`r�ZXYZZ
OpenActionr�r�fitZFitZfithr�ZFitHZfitbhr6r�r?�splitZFitBHr8r�rZsingleZ
SinglePageZ	onecolumnZ	OneColumnZtwocolumnrightZTwoColumnRightZ
twocolumnleftZ
TwoColumnLeftreZInfordri)rE�outputstreamr�r�r�r�Z
NullObjectZ
TrueObjectr^r�r��imgwidthrrrri9s�
�����������

�
��zpdfdoc.tostream)rYNNNNNNNNFNNNNFFFT)NNFrr)rrrrJr�rKrirrrrrZs6�
h�
~rcCs�|tjkrN|dk	rN|dkrNt|�\}}}}}	|dkr8|}|	dkrD|}	||	f}
nB|j\}}|j�d||f�}
tt|
d��tt|
d��f}
|j}|dks�d|jkr�t	�
d�t	�
d�t	�
d�t	�
d	�td
��|
dkr�||f}
|
dk�r|tjk�r|j
�tj|�|j
�tj|�f}
t	jd!|
��d}t|d��r�|��dk	�r�|����D]�\}}
t�||�dk�rP|
dk�rzd}n`|
dk�r�d}nP|
dk�r�d}n@|
dk�r�d}n0|
dk�r�tdtj|
f��ntdtj|
f���qPt	�d|�|�r|}t	�d|�n�d}tD]}|j|k�r
|}�q
|dk�r`|dk	�rX|tjk�rX|ddk�rXtj}ntd��|tjk�r�|tjk�r�d|jk�r�td}t	�d|j�t	�d ||�||
|||fS)"N�dpirr�)ZLAZPA�RGBAZtransparencyz<Image contains transparency which cannot be retained in PDF.z+img2pdf will not perform a lossy operation.z3You can remove the alpha channel using imagemagick:zK  $ convert input.png -background white -alpha remove -alpha off output.pngz-Refusing to work on images with alpha channel�rr)r�r��input dpi = %d x %d�_getexifZOrientationrsrmr	r@r#i)rSr3r�r�z2Image "%s": Unsupported flipped rotation mode (%d)z!Image "%s": invalid rotation (%d)urotation = %d°zinput colorspace (forced) = %sr�zunknown colorspaceZadober�zinput colorspace = %szwidth x height = %dpx x %dpx)r�)r
r�r�sizere�getr3�round�mode�logging�warningr��TIFF�tag_v2rZX_RESOLUTIONZY_RESOLUTION�debugr:r�r2r�imrRrr�r�r�r�r�)r�r��default_dpir��rawdatar�r�ZicsZhdpiZvdpi�ndpi�rotation�tagrIr�r-rrr�get_imgmetadata�s�

 �

��




���
��
�r�cCs�|jddkr td|jd��|jtj}|jtj}|j�tjd�}t|�dks`t|�dkrht	d��||\}\}t
�d|�t
�d|�||fS)	N�compression�group4z4Image not compressed with CCITT Group 4 but with: %sl��r�z)Transcoding multiple strips not supportedzTIFF strip_offsets: %dzTIFF strip_bytes: %d)rer�r�r�STRIPOFFSETSZSTRIPBYTECOUNTSr�ZROWSPERSTRIPrA�NotImplementedErrorr�r�)�imgZ
strip_offsetsZstrip_bytesZrows_per_strip�offset�lengthrrr�ccitt_payload_location_from_pil2s��r�cCsjt�d�t�}t�|j|j|���}|j|ddd�|�	d�t�
|�}t|�\}}|�	|�|�|�S)zBConvert the open PIL.Image imgdata to compressed CCITT Group4 dataz%Converting monochrome to CCITT Group4r�r�)�formatr�r)
r�r�rrZ	frombytesr�r��tobytes�save�seek�openr��read)r�Znewimgior��newimgr�r�rrr�transcode_monochromeOs



r�c	Cs�d}g}d}|t|�kr�t�d||d|d��\}||t|�kr\td||t|�f��||d|�dkr�|||||�7}nR||d|�dkr�t|||d	�D],}t�dd
|||d	��\}|�|�q�||7}|d7}q||fS)N�rz>Ir#r3zinvalid png: %d %d %dsIDATsPLTEr	�rC)rA�structZunpackr��rangera)r��pngidatr��i�n�jr�rrr�	parse_pngis 

r�FcCs�t|�}|�d�d}zt�|�}WnDtk
rh}z&|dd�dkrRtd|��tj}W5d}~XYn.Xd}tD]}|j|j	krr|}qr|dkr�tj
}t�d|j�|tj
ks�|tjk�r>t||t||�\}}	}
}}|tdkr�td��|tdkr�td	��|td
k�rtd��|��t�d�||	|||
|gd
d|f
gS|tjk�r�|ddk�r�t||t||�\}}	}
}}t|�\}
}|��|d}|dk�r�td|��t�d�||	||
|
||d
||f
gSg}d}z|�|�Wntk
�r�Y�qpYnX|�r|dk�r�qp|tjk�r@t|j�tjdg��dk�r@td��|tjk�r�|jddk�r�t|jtj�dk�r�|jtj }d
}|dk�r�d}n|dk�r�td|��t||t||�\}}	}
}}t!|�\}}|�|�|�"|�}|j�tj#�}|dk�r�nb|dk�rnV|dk�rRt�d�t$|�}t%t|��D]}t&||||<�q0t'|�}ntd|��t�d�|�(||	tj)||
|g|d|f
�|d7}�q�t�d|�t||t|�\}}	}
}}d}|tdk�r\zDt*|�}t�d�|�(||	tj)||
|gd
d|f
�|d7}W�q�WnHt+k
�rX}z(t�|�t�d �|�,d!�}tj-}W5d}~XYnXn@|tj.tj-tj/td"tj0fk�r�t�d#|�|}ntd$|j��|tj/td"fk�r�t1�2|�3��}t�d%�|�(||	|||
|gd
d|f
�n|t�}|j4|d&d'�t|�5��\}
}|�d�t6|�"d��}|dk�r:td|��t�d(�|�(||	tj|
|
||d
||f
�|d7}�q�z|��Wnt7k
�r�YnX|��|S))NrrCsjP  
�
zDcannot read input image (not jpeg2000). PIL: error reading image: %szimgformat = %sr�zjpeg can't be monochromer�zjpeg can't have a color paletter�z jpeg can't have an alpha channelzread_images() embeds a JPEGFr#rKr+)r�rSr3r#rzinvalid bit depth: %dzread_images() embeds a PNGr�z5PIL is unable to preserve more than 8 bits per sampler�r�Tz:unsupported photometric interpretation for group4 tiff: %drSz'fillorder is lsb-to-msb => reverse bitszunsupported FillOrder: %dz%read_images() embeds Group4 from TIFFzConverting frame: %dz2read_images() encoded a B/W image as CCITT group 4zConverting colorspace 1 to Lr�r�zColorspace is OK: %sz%unknown or unsupported colorspace: %sz1read_images() encoded CMYK with flate compressionZpng)r�z%read_images() encoded an image as PNG)8rr�rr��IOErrorrr
r�rRr��otherr�r�r�r�r�rr�closer�r�r��EOFErrorr��maxr�r�rZ
BITSPERSAMPLErerAr�ZPHOTOMETRIC_INTERPRETATIONr�r�Z	FILLORDER�	bytearrayr��TIFFBitRevTabler<rar�r�r��convertr�r�r�r��zlib�compressr�r�r��ord�AttributeError)r�r��first_frame_onlyr�r��er��fr�r�r�r�r�r�r�r��resultZimg_page_countZphotor�r�r�Z	fillorderr�r�Z	ccittdataZimggzZ	pngbufferrrr�read_images�s�
���
���

��
�����

���







���
��



�
��


��r	cCsd||S�N�R@r)r�r�rrr�px_to_pt�srcCsd|dS)NrgR���Q@r�r�rrr�cm_to_pt�srcCsd|dS)Nrgffffff9@rr
rrr�mm_to_pt�srcCsd|Sr
rr
rrr�in_to_pt�srcs�dd���dkr$�dkr$�dkr$tS�dkrL�dkrL�dk	rL�fdd�}|S�dkrXd��dk	r��dkr������fdd�}|Sdd���dkr��dk	r������fd	d�}|S�dk	rڈdk	rڇ�����fd
d�}|St�dS)Ncs�dkr�dkrtd��|tjtjfkrR�dk	rR�dkrR�dk	rR�dkrRtd��n8|tjtjfkr��dk	rr�dks��dk	r��dkr�td������fdd�}|dks�|tjkr�|�S|tjk�rV�dk	r��dk	r��}|��}|�kr��}|��}nT�dk�r �dk	�r �}|��}n.�dk�rF�dk	�rF�}|��}ntd��||fS|tjk�rڈdk	�r~�dk	�r~��fS�dk�r��dk	�r��}|��}n.�dk�rʈdk	�rʈ}|��}ntd��||fS|tjk�rv�dk	�r�dk	�r��k�rp��k�rp��fSnX�dk�r@�dk	�r@��k�rp��fSn0�dk�rh�dk	�rh��k�rp��fSntd��|�S|tjk�r�dk	�r��dk	�r���k�s���k�r��fSnX�dk�r܈dk	�r܈�k�r��fSn0�dk�r�dk	�r��k�r��fSntd��|�St�dS)N�*fitwidth and fitheight cannot both be Nonerz>cannot fit into a rectangle where both dimensions are negativez@cannot fit into a rectangle where either dimensions are negativecs��dk	r:�dk	r:�}|��}|�kr��}|��}nL�dkr\�dk	r\�}|��}n*�dkr~�dk	r~�}|��}ntd��||fS)Nr)r�)�newimgwidth�newimgheight��	fitheight�fitwidth�	imgheightr�rr�default�sz/get_layout_fun.<locals>.fitfun.<locals>.default)	r�r
�fill�enlarger��into�exactZshrinkr�)r�r�rrrrrrrrr�fitfun�s������������









zget_layout_fun.<locals>.fitfuncsHt||d�}t||d�}|d�d}|d�d}||||fS�Nrr�rS�r�r�r�r�r�r�r�r�)�borderrr�
layout_fun&s
z"get_layout_fun.<locals>.layout_funr�c
s��ddk	rp�ddk	rp�rp||kr4�d�dksL||krp�d�dkrp�d�d}}�d�df}n�d�d}}�}|dk	r�|d|d}nd}|dk	r�|d|d}nd}�tjtjfk�r|dk	�r|dk�r|dk	�r|dk�rtd��nB�tjtjfk�rH|dk	�r,|dk�s@|dk	�rH|dk�rHtd����t||d�t||d�||�\}}	|dk�r�|�dd}|dk�r�|	�dd}||||	fS)Nrr�rSzVat least one border dimension musts be smaller than half the respective page dimensionzIone border dimension is larger than half of the respective page dimension)r
rrrr)
r�r�r�r�r�Z	newborderrrr�r�)�auto_orientr!r�r�pagesizerrr"5sz
�
������	������������

cSsZ|dkrdS|\}}|tjkr"|S|tjkr>t||�|dS|tjkrRt||�St�dS)Nr9)r�abs�percrr�r�)�sZpxr�r�rIrrr�
scale_imgsizens



z%get_layout_fun.<locals>.scale_imgsizec
st��t||d�t||d���d||d���d||d��\}}|d�d}|d�d}||||fSrrr )r!r�r�imgsizer(rrr"|s�c
s��ddk	r`�ddk	r`�r`||kr4�d�dksL||kr`�d�dkr`�d�d}}n�d�d}}��t||d�t||d���d||d���d||d��\}}||||fS�Nrr�r)r�r�r�r�r�r�r�)r#r�rr)r$r(rrr"�s0
�
������	�)�default_layout_funr�)r$r)r!r�r#r"r)r#r!r�rr)r$r(r�get_layout_fun�s&f7r,cCs0t||d�}}t||d�}}||||fSr*r)r�r�r�r�r�r�r�rrrr+�sr+cs�fdd�}|S)z�Layout function that overrides whatever DPI is claimed in input images.

    >>> layout_fun = get_fixed_dpi_layout_fun((300, 300))
    >>> convert(image1, layout_fun=layout_fun, ... outputstream=...)
    cst||��Sr)r+)r�r�r���	fixed_dpirr�fixed_dpi_layout_fun�sz6get_fixed_dpi_layout_fun.<locals>.fixed_dpi_layout_funr)r.r/rr-r�get_fixed_dpi_layout_fun�sr0cCs2ddlm}m}t||�}|d}d|||��S)z�Find the power of 10 (10, 100, 1000...) that will reduce the scale
    below the PDF specification limit of 14400 PDF units (=200 inches)r)�log10�ceil� �@rc)Zmathr1r2r�)r�r�r1r2�majorZ	oversizedrrr�
find_scale�s
r5cOs�tddddddddddtdddddddddddd�}|��D]\}}||kr<|||<q<td|d|d|d|d|d	|d
|d|d|d
|d|d|d|d|d|d|d|d�}t|�dkr�t|dttf�r�|d}t|ttf�s�|g}|D�]~}z|��}Wnlt	k
�r�t|t
tf��s>td��z"t
|d��}|��}W5QRXWntk
�rz|}YnXYnXt||d|d�D]�\
}	}
}}}
}}}}}|d|
||
�\}}}}d}|dk�s�|dk�r�t�d�nR|dk�s�|dk�r<|d �r4t||�}||}||}||}||}ntd!��||d"}||d"}|�|	|
||||||||||||||��q��q|d#�r�|�|d#�dS|��S)$NFT)r�r�r�r�r�r�r�r�r�r�r"�viewer_panes�viewer_initial_page�viewer_magnification�viewer_page_layout�viewer_fit_window�viewer_center_window�viewer_fullscreenr�r�r�allow_oversizedrYr�r�r�r�r�r�r�r�r�r6r7r8r9r:r;r<r�r�rz-Neither implements read() nor is str or bytes�rbr�rr"g@z?pdf width or height is below 3.00 - too small for some viewers!r3r=z/pdf width or height must not exceed 200 inches.g@r�)r/r+r2rrAr8r>�tupler�rr4r<r=r�r�r	r�r�r5rr�rirK)�images�kwargsZ_default_kwargsZkwnamerZpdfr�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�s��
�

���


��
rcCs&|dkrdSd}|�d�r"tj}nn|�d�r4tj}n\|�d�rFtj}nJ|�d�rXtj}n8zt|�}Wn*tk
r�d||f}t�	|��YnX|dkr�tj}nD|dd�}zt|�}Wn*tk
r�d||f}t�	|��YnX|tjkr�t
|�}n*|tjk�rt|�}n|tjk�r"t|�}|S)	Nr��pt�cm�mm�in�C%s is not a floating point number and doesn't have a valid unit: %s����%%s is not a floating point number: %s)
�endswithrrBrCrD�inchr6r��argparse�ArgumentTypeErrorrrr�ZnumrRZunit�msgrrr�	parse_numWsD



��


rOcCs�|dkrdSd}|�d�r"tj}n�|�d�r4tj}n�|�d�rFtj}nn|�d�rXtj}n\|�d�rjtj}nJ|�d�r|tj}n8zt|�}Wn*t	k
r�d||f}t
�|��YnX|dkr�tj}nv|tjkr�|dd	�}n$|tjkr�|dd
�}n|dd�}zt|�}Wn,t	k
�r8d||f}t
�|��YnX|tjk�rVtj
t|�f}n~|tjk�rrtj
t|�f}nb|tjk�r�tj
t|�f}nF|tjk�r�tj
|f}n.|tjk�r�tj|f}n|tjk�r�tj|f}|S)
Nr�rBrCrDrEr��%rF���r�rGrH)rIrrBrCrDrJr�r&r6r�rKrLrr%rrrrMrrr�parse_imgsize_num~s`





��


rRcCs�|�d�}|r|dd�}t�|���r4t|��}d|krLt|d�}d}n$|�dd�\}}t|d�}t|d�}|r~||}}|dkr�|dkr�t�d��||fS�Nz^TrGrh�widthr�Zheightz(at least one dimension must be specified)rI�
papersizesr��lowerrOr�rKrL�rZ
transposed�w�hrrr�parse_pagesize_rectarg�s 





rZcCs�|�d�}|r|dd�}t�|���r4t|��}d|krLt|d�}d}n$|�dd�\}}t|d�}t|d�}|r~||}}|dkr�|dkr�t�d��||fSrS)rIrUr�rVrRr�rKrLrWrrr�parse_imgsize_rectarg�s 





r[cCsFtD]}|j|kr|Sqd�dd�tD��}t�d||f��dS)N�, cSsg|]
}|j�qSr�rRr,rrrr)�sz'parse_colorspacearg.<locals>.<listcomp>z/Unsupported colorspace: %s. Must be one of: %s.)rrRr0rKrL)rr-�allowedrrr�parse_colorspacearg�s


�r_cCs�d|kr>|�dd�\}}|dkr*t�d��|dkrZt�d��n|dkrPt�d��||}}t|d�t|d�}}|dkr�|dkr�t�d	��||fS)
N�:r�r�zmissing value before colonzmissing value after colonzborder option cannot be emptyzleft/right borderztop/bottom borderz
missing value)r�rKrLrO)rrYr&rrr�parse_borderarg�s



rac
Cs�|dkrBtrtjj��}n
tj��}t|�dkr>t�d|���nXtr�zBtj	�
|�dkrft�d|��t|d��}|�d�W5QRXWnbtk
r�t�d|��YnBt
k
r�t�d|��Yn"tk
r�t�d|��YnXn�zDtj	�
|�dk�rt�d|��t|d��}|�d�W5QRXWnbtk
�rd}zt�t|���W5d}~XYn2tk
�r�}zt�t|���W5d}~XYnX|}|S)	N�-rz
"%s" is emptyr>r�z"%s" is a directoryz"%s" permission deniedz"%s" does not exist)�PY3�sys�stdin�bufferr�rArKrL�os�path�getsizer��IsADirectoryError�PermissionError�FileNotFoundErrorr�r4�OSError)rhrr��errrrr�input_images�s:
 rocCs2tD]}|j|��kr|Sqt�d|��dS)Nzunknown fit mode: %s)r
rRrVrKrL)r�mrrr�parse_fitarg$s
rqcCsJtD]}|j|��kr|Sqd�dd�tD��}t�d||f��dS)Nr\cSsg|]
}|j�qSrr]�r$rprrrr)/szparse_panes.<locals>.<listcomp>z.Unsupported page mode: %s. Must be one of: %s.)rrRrVr0rKrL�rrpr^rrr�parse_panes+s

�rtcCsjtD]}|j|��kr|Sqz
t|�WStk
r>YnXd�dd�tD��}t�d||f��dS)Nr\cSsg|]
}|j�qSrr]rrrrrr)=sz'parse_magnification.<locals>.<listcomp>zMUnsupported magnification: %s. Must be a floating point number or one of: %s.)rrRrVr6r�r0rKrLrsrrr�parse_magnification5s

��rucCsJtD]}|j|��kr|Sqd�dd�tD��}t�d||f��dS)Nr\cSsg|]
}|j�qSrr])r$�lrrrr)Hsz parse_layout.<locals>.<listcomp>z0Unsupported page layout: %s. Must be one of: %s.)rrRrVr0rKrL)rrvr^rrr�parse_layoutDs

�rwcCs&zt�|d�WStk
r"YnXzt�|d�WStk
rFYnXzt�|d�WStk
rjYnXzddlm}Wntk
r�Yn$Xz|�|�WStk
r�YnXzddl}Wntk
r�Yn@Xz|�	dd|dg�}Wn|j
k
�rYnXt�t|��St
�d	|��dS)
Nz%Y-%m-%dz%Y-%m-%dT%H:%Mz%Y-%m-%dT%H:%M:%Sr)�parser�datez--datez+%szcannot parse date: %s)r�strptimer�Zdateutilrxr�r#r=�
subprocessZcheck_outputZCalledProcessErrorZutcfromtimestampr3rKrL)rrxr{�utimerrr�
valid_dateNs<r}c
Cs�d}tt���D]\}}|dt||f7}qtjtjdd|d�}|jddtdd	d
�|jddd
dd�|jddddt	dd�|j
ddd�}|jdddt�d�tt
jd�r�t
jjnt
jdd�|jd d!d"td#d$�|jd%d&d
d'd�|jd(d
d)d�|jd*d
d+d�|jd,d
d-tjd�|j
d.d/td�}|jd0d1d2td3d$�|jd4d5d2td6d$�|jd7d8d9td:d$�|jd;d<d=ttjd>d�|jd?d@d
dAd�|j
dBdCd�}|jdDdEtdFd$�|jdGdHtdId$�|jdJdKtdLd$�|jdMdNtdOt	dPt	dQd�|jdRdStdTd$�|jdUdVtdWd$�|jdXdYtdZd$�|jd[d\td]d^d
�|j
d_d`d�}|jdadbtdcd$�|jdddetdfd$�|jdgdhtdid$�|jdjdktdld$�|jdmd
dnd�|jdod
dpd�|jdqd
drd�|� |dsd��}	|	j!�r�t"j#t"j$dt�|	j%�rdt_t&|	j'|	j(|	j)|	j*|	j+�}
t,|	j-�duk�r~t"�.dv�z*t/�rNt
j0j�1�g|	_-nt
j0�1�g|	_-Wnt2k
�r|t3du�YnX|	j4dk	�r�|	j4dsk�r�|j5t
j6dw�t"�7dx|j8�t3dy�|	j4t,|	j-�k�r�|j5t
j6dw�t"�7dz|j8�t3dy�zft9|	j-|	j:|	j;|	j<|	j=|	j>|	j?|	j@|	jA|	jB|	jC|
|	jD|	j4|	jE|	jF|	jG|	jH|	jI|	jJ|	jK|	jLd{��WnftMk
�r�}zFt"�7d|t|��t"�N��Ot"j$��r�dudlP}|jQt
j6dw�t3ds�W5d}~XYnXdS)}Nr�z    %-8s %s
a�Losslessly convert raster images to PDF without re-encoding PNG, JPEG, and
JPEG2000 images. This leads to a lossless conversion of PNG, JPEG and JPEG2000
images with the only added file size coming from the PDF container itself.
Other raster graphics formats are losslessly stored using the same encoding
that PNG uses. Since PDF does not support images with transparency and since
img2pdf aims to never be lossy, input images with an alpha channel are not
supported.

The output is sent to standard output so that it can be redirected into a file
or to another program as part of a shell pipe. To directly write the output
into a file, use the -o or --output option.

Options:
aColorspace:
  Currently, the colorspace must be forced for JPEG 2000 images that are not in
  the RGB colorspace.  Available colorspace options are based on Python Imaging
  Library (PIL) short handles.

    RGB      RGB color
    L        Grayscale
    1        Black and white (internally converted to grayscale)
    CMYK     CMYK color
    CMYK;I   CMYK color with inversion (for CMYK JPEG files from Adobe)

Paper sizes:
  You can specify the short hand paper size names shown in the first column in
  the table below as arguments to the --pagesize and --imgsize options.  The
  width and height they are mapping to is shown in the second column.  Giving
  the value in the second column has the same effect as giving the short hand
  in the first column. Appending ^T (a caret/circumflex followed by the letter
  T) turns the paper size from portrait into landscape. The postfix thus
  symbolizes the transpose. The values are case insensitive.

%s

Fit options:
  The img2pdf options for the --fit argument are shown in the first column in
  the table below. The function of these options can be mapped to the geometry
  operators of imagemagick. For users who are familiar with imagemagick, the
  corresponding operator is shown in the second column.  The third column shows
  whether or not the aspect ratio is preserved for that option (same as in
  imagemagick). Just like imagemagick, img2pdf tries hard to preserve the
  aspect ratio, so if the --fit argument is not given, then the default is
  "into" which corresponds to the absence of any operator in imagemagick.
  The value of the --fit option is case insensitive.

    into    |   | Y | The default. Width and height values specify maximum
            |   |   | values.
   ---------+---+---+----------------------------------------------------------
    fill    | ^ | Y | Width and height values specify the minimum values.
   ---------+---+---+----------------------------------------------------------
    exact   | ! | N | Width and height emphatically given.
   ---------+---+---+----------------------------------------------------------
    shrink  | > | Y | Shrinks an image with dimensions larger than the given
            |   |   | ones (and otherwise behaves like "into").
   ---------+---+---+----------------------------------------------------------
    enlarge | < | Y | Enlarges an image with dimensions smaller than the given
            |   |   | ones (and otherwise behaves like "into").

Argument parsing:
  Argument long options can be abbreviated to a prefix if the abbreviation is
  unambiguous. That is, the prefix must match a unique option.

  Beware of your shell interpreting argument values as special characters (like
  the semicolon in the CMYK;I colorspace option). If in doubt, put the argument
  values in single quotes.

  If you want an argument value to start with one or more minus characters, you
  must use the long option name and join them with an equal sign like so:

    $ img2pdf --author=--test--

  If your input file name starts with one or more minus characters, either
  separate the input files from the other arguments by two minus signs:

    $ img2pdf -- --my-file-starts-with-two-minuses.jpg

  Or be more explicit about its relative path by prepending a ./:

    $ img2pdf ./--my-file-starts-with-two-minuses.jpg

  The order of non-positional arguments (all arguments other than the input
  images) does not matter.

Examples:
  Lines starting with a dollar sign denote commands you can enter into your
  terminal. The dollar sign signifies your command prompt. It is not part of
  the command you type.

  Convert two scans in JPEG format to a PDF document.

    $ img2pdf --output out.pdf page1.jpg page2.jpg

  Convert a directory of JPEG images into a PDF with printable A4 pages in
  landscape mode. On each page, the photo takes the maximum amount of space
  while preserving its aspect ratio and a print border of 2 cm on the top and
  bottom and 2.5 cm on the left and right hand side.

    $ img2pdf --output out.pdf --pagesize A4^T --border 2cm:2.5cm *.jpg

  On each A4 page, fit images into a 10 cm times 15 cm rectangle but keep the
  original image size if the image is smaller than that.

    $ img2pdf --output out.pdf -S A4 --imgsize 10cmx15cm --fit shrink *.jpg

  Prepare a directory of photos to be printed borderless on photo paper with a
  3:2 aspect ratio and rotate each page so that its orientation is the same as
  the input image.

    $ img2pdf --output out.pdf --pagesize 15cmx10cm --auto-orient *.jpg

  Encode a grayscale JPEG2000 image. The colorspace has to be forced as img2pdf
  cannot read it from the JPEG2000 file automatically.

    $ img2pdf --output out.pdf --colorspace L input.jp2

Written by Johannes 'josch' Schauer <josch@mister-muffin.de>

Report bugs at https://gitlab.mister-muffin.de/josch/img2pdf/issues
)Zformatter_class�descriptionZepilogr@Zinfile�*a�Specifies the input file(s) in any format that can be read by the Python Imaging Library (PIL). If no input images are given, then a single image is read from standard input. The special filename "-" can be used once to read an image from standard input. To read a file in the current directory with the filename "-", pass it to img2pdf by explicitly stating its relative path like "./-".)�metavarr.�nargs�helpz-vz	--verbose�
store_truezOMakes the program operate in verbose mode, printing messages on standard error.)�actionr�z-Vz	--versionr_z	%(prog)s z%Prints version information and exits.)r�r_r�zGeneral output argumentsz(Arguments controlling the output format.)r�r~z-oz--output�out�wbrfz>Makes the program output to a file instead of standard output.)r�r.rr�z-Cz--colorspacer�a�
Forces the PIL colorspace. See the epilogue for a list of possible values.
Usually the PDF colorspace would be derived from the color space of the input
image. This option overwrites the automatically detected colorspace from the
input image and thus forces a certain colorspace in the output PDF /ColorSpace
property. This is useful for JPEG 2000 images with a different colorspace than
RGB.)r�r.r�z-Dz--nodatez�Suppresses timestamps in the output and thus makes the output deterministic between individual runs. You can also manually set a date using the --moddate and --creationdate options.z--without-pdfrwa�By default, img2pdf uses the pdfrw library to create the output PDF if pdfrw is available. If you want to use the internal PDF generator of img2pdf even if pdfrw is present, then pass this option. This can be useful if you want to have unicode metadata values which pdfrw does not yet support (See https://github.com/pmaupin/pdfrw/issues/39) or if you want the PDF code to be more human readable.z--first-frame-onlyz�By default, img2pdf will convert multi-frame images like multi-page TIFF or animated GIF images to one page per frame. This option will only let the first frame of every multi-frame input image be converted into a page in the resulting PDF.z--pillow-limit-breaka3img2pdf uses the Python Imaging Library Pillow to read input images. Pillow limits the maximum input image size to %d pixels to prevent decompression bomb denial of service attacks. If your input image contains more pixels than that, use this option to disable this safety measure during this run of img2pdfz(Image and page size and layout argumentsa�
Every input image will be placed on its own page. The image size is controlled
by the dpi value of the input image or, if unset or missing, the default dpi of
%.2f. By default, each page will have the same size as the image it shows.
Thus, there will be no visible border between the image and the page border by
default. If image size and page size are made different from each other by the
options in this section, the image will always be centered in both dimensions.

The image size and page size can be explicitly set using the --imgsize and
--pagesize options, respectively.  If either dimension of the image size is
specified but the same dimension of the page size is not, then the latter will
be derived from the former using an optional minimal distance between the image
and the page border (given by the --border option) and/or a certain fitting
strategy (given by the --fit option). The converse happens if a dimension of
the page size is set but the same dimension of the image size is not.

Any length value in below options is represented by the meta variable L which
is a floating point value with an optional unit appended (without a space
between them). The default unit is pt (1/72 inch, the PDF unit) and other
allowed units are cm (centimeter), mm (millimeter), and in (inch).

Any size argument of the format LxL in the options below specifies the width
and height of a rectangle where the first L represents the width and the second
L represents the height with an optional unit following each value as described
above.  Either width or height may be omitted. If the height is omitted, the
separating x can be omitted as well. Omitting the width requires to prefix the
height with the separating x. The missing dimension will be chosen so to not
change the image aspect ratio. Instead of giving the width and height
explicitly, you may also specify some (case-insensitive) common page sizes such
as letter and A4.  See the epilogue at the bottom for a complete list of the
valid sizes.

The --fit option scales to fit the image into a rectangle that is either
derived from the --imgsize option or otherwise from the --pagesize option.
If the --border option is given in addition to the --imgsize option while the
--pagesize option is not given, then the page size will be calculated from the
image size, respecting the border setting. If the --border option is given in
addition to the --pagesize option while the --imgsize option is not given, then
the image size will be calculated from the page size, respecting the border
setting. If the --border option is given while both the --pagesize and
--imgsize options are passed, then the --border option will be ignored.

z-Sz
--pagesizeZLxLz�
Sets the size of the PDF pages. The short-option is the upper case S because
it is an mnemonic for being bigger than the image size.z-sz	--imgsizea�
Sets the size of the images on the PDF pages.  In addition, the unit dpi is
allowed which will set the image size as a value of dots per inch.  Instead of
a unit, width and height values may also have a percentage sign appended,
indicating a resize of the image by that percentage. The short-option is the
lower case s because it is an mnemonic for being smaller than the page size.
z-bz--borderzL[:L]aM
Specifies the minimal distance between the image border and the PDF page
border.  This value Is overwritten by explicit values set by --pagesize or
--imgsize.  The value will be used when calculating page dimensions from the
image dimensions or the other way round. One, or two length values can be given
as an argument, separated by a colon. One value specifies the minimal border on
all four sides. Two values specify the minimal border on the top/bottom and
left/right, respectively. It is not possible to specify asymmetric borders
because images will always be centered on the page.
z-fz--fitZFITa

If --imgsize is given, fits the image using these dimensions. Otherwise, fit
the image into the dimensions given by --pagesize.  FIT is one of into, fill,
exact, shrink and enlarge. The default value is "into". See the epilogue at the
bottom for a description of the FIT options.

z-az
--auto-orienta
If both dimensions of the page are given via --pagesize, conditionally swaps
these dimensions such that the page orientation is the same as the orientation
of the input image. If the orientation of a page gets flipped, then so do the
values set via the --border option.
zArguments setting metadatazCOptions handling embedded timestamps, title and author information.z--titler�zSets the title metadata valuez--authorr�zSets the author metadata valuez	--creatorr�zSets the creator metadata valuez
--producerr�zimg2pdf z6Sets the producer metadata value (default is: img2pdf �)z--creationdater�z�Sets the UTC creation date metadata value in YYYY-MM-DD or YYYY-MM-DDTHH:MM or YYYY-MM-DDTHH:MM:SS format or any format understood by python dateutil module or any format understood by `date --date`z	--moddater�z�Sets the UTC modification date metadata value in YYYY-MM-DD or YYYY-MM-DDTHH:MM or YYYY-MM-DDTHH:MM:SS format or any format understood by python dateutil module or any format understood by `date --date`z	--subjectr�zSets the subject metadata valuez
--keywordsrG�+z>Sets the keywords metadata value (can be given multiple times)zPDF viewer argumentszTPDF files can specify how they are meant to be presented to the user by a PDF viewerz--viewer-panesZPANESz�Instruct the PDF viewer which side panes to show. Valid values are "outlines" and "thumbs". It is not possible to specify both at the same time.z--viewer-initial-pageZNUMzuInstead of showing the first page, instruct the PDF viewer to show the given page instead. Page numbers start with 1.z--viewer-magnificationZMAGz�Instruct the PDF viewer to open the PDF with a certain zoom level. Valid values are either a floating point number giving the exact zoom level, "fit" (zoom to fit whole page), "fith" (zoom to fit page width) and "fitbh" (zoom to fit visible page width).z--viewer-page-layoutZLAYOUTa4Instruct the PDF viewer how to arrange the pages on the screen. Valid values are "single" (display single pages), "onecolumn" (one continuous column), "twocolumnright" (two continuous columns with odd number pages on the right) and "twocolumnleft" (two continuous columns with odd numbered pages on the left)z--viewer-fit-windowzAInstruct the PDF viewer to resize the window to fit the page sizez--viewer-center-windowz7Instruct the PDF viewer to center the PDF viewer windowz--viewer-fullscreenz:Instruct the PDF viewer to open the PDF in fullscreen moder�)�levelrz!reading image from standard input)�filezD%s: error: argument --viewer-initial-page: must be greater than zerorSzb%s: error: argument --viewer-initial-page: must be less than or equal to the total number of pages)r�r�r�r�r�r�r�r�r�r�r"r6r7r8r9r:r;r<r�r�rzerror: )Rr1rUr2�
papernamesrK�ArgumentParserZRawDescriptionHelpFormatter�add_argumentro�__version__Zadd_argument_groupZFileTyper:rd�stdoutrfr_rZMAX_IMAGE_PIXELSr�rZr[rarqr
rr4r}rtr3rurw�
parse_args�verboser�ZbasicConfig�DEBUGZpillow_limit_breakr,r$r)r!r�r#rAr@rercrer��KeyboardInterrupt�exitr7Zprint_usage�stderr�error�progrr�r�r�r�r�r�r�r�r�r�r6r8r9r:r;r<Z
without_pdfrw�outputrr�Z	getLoggerZisEnabledFor�	traceback�	print_exc)
�argvZrendered_papersizesr%r&rxZoutargsZsizeargsZmetaargsZ
viewerargsrFr"rr�rrr�mainus6l������
���	��	��+��0�
�
�����������	�	������
�
����
�����r��__main__)r�)N)F)NNNNF)RrdrgrrKZPILrrZPIL.ExifTagsrrZjp2r�enumr�iorr�r��version_inforcr�r�rUr�r
rrr
rrrrrrr�r�rrrrrrr#�objectr9rCr<rTr>rWrXrlrr�r�r�r�r	rrrrr,r+r0r5rrOrRrZr[r_rarorqrtrurwr}r�r�rrrrr�<module>s��
�









��((Yeu#�m
'7
(

'