
    SAi             	       N   S r SrSSKrSSKrSSKrSSKrSSKJrJrJ	r	J
r
Jr  \" \	S5      (       a  \	R                  R                  \	l        SSKJr  SSKJrJr  SSKJr  SS	KJr  SSKrSSKrSSKrSSKrSS
KJr  SSKrSSKr\R>                  " \ 5      r!Sr" SSK#r#Sr% SSK&r&Sr'0 SS_SS_SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S%_S&S'_S(S)_S*S+_S,S-_S.S/_S0S1S2S3S4S5S6S7.Er(0 SS8_SS9_SS:_SS;_SS<_SS=_SS>_SS?_SS@_S SA_S"SB_S$SC_S&SD_S(SE_S*SF_S,SG_S.SH_SISJSKSLSMSNSOS7.Er)\" SPSQ5      r*\" SRSS5      r+\" STSU5      r,\" SVSW5      r-\" SXSY5      r.\" SZS[5      r/\" S\S]5      r0\" S^S_5      r1\" S`Sa5      r2\" SbSc5      r3\" SdSe5      r4\" SfSg5      r5/ ShQr6 " Si Sj\75      r8 " Sk Sl\75      r9 " Sm Sn\75      r: " So Sp\75      r; " Sq Sr\75      r< " Ss St\75      r= " Su Sv\75      r> " Sw Sx5      r? " Sy Sz5      r@S{ rASS| jrB " S} S~\C5      rD " S S5      rE\E" 5       rE " S S\F5      rG " S S\H5      rI " S S5      rJ " S S5      rK " S S\C5      rLS rM SS jrNS rOS rPS rQ\R                  " S\R                  5      rTS rU SS jrVS rWS rXS rYS rZS r[ SS jr\S r]S r^S r_S r`SS.S jraS rbS rcS rdS reS rfS rgS rhS riS rjS rkS rlS rmS rnS roS rpS rqS rrS rsS rtS ru\R                  4S jrw\ S:X  a  \w" 5         gg! \$ a    Sr" GNwf = f! \$ a    Sr% GNf = f)z.
Lossless conversion of raster images to PDF.
z0.6.3    N)ImageTiffImagePluginGifImagePluginImageCmsExifTagsLoadingStrategy)TAGS)datetimetimezone)Enum)BytesIO)chainTFg      X@letterz
8.5inx11ina0841mmx1189mma1594mmx841mma2420mmx594mma3297mmx420mma4210mmx297mma5148mmx210mma6105mmx148mmb01000mmx1414mmb1707mmx1000mmb2500mmx707mmb3353mmx500mmb4250mmx353mmb5176mmx250mmb6125mmx176mmjb01030mmx1456mmjb1728mmx1030mm515mmx728mm364mmx515mm257mmx364mm182mmx257mm128mmx182mmz
8.5inx14in	11inx17in)jb2jb3jb4jb5jb6legaltabloidLetterA0A1A2A3A4A5A6B0B1B2B3B4B5B6JB0JB1JB2JB3JB4JB5JB6LegalTabloidEnginezinternal pdfrw pikepdfRotationzauto none ifvalid 0 90 180 270FitModezinto fill exact shrink enlargePageOrientationzportrait landscape
Colorspacez&RGB RGBA L LA 1 CMYK CMYK;I P PA otherImageFormatz;JPEG JPEG2000 CCITTGroup4 PNG GIF TIFF MPO MIFF JBIG2 otherPageModeznone outlines thumbs
PageLayoutzFsingle onecolumn twocolumnright twocolumnleft twopageright twopageleftMagnificationzfit fith fitbhImgSizezabs perc dpiUnitzpt cm mm inchImgUnitzpt cm mm inch perc dpi(   r      @             `            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                       \ rS rSrSrg)NegativeDimensionErrori   N__name__
__module____qualname____firstlineno____static_attributes__rb      C/var/www/html/land-ocr/venv/lib/python3.13/site-packages/img2pdf.pyra  ra        ri  ra  c                       \ rS rSrSrg)UnsupportedColorspaceErrori  rb  Nrc  rb  ri  rj  rm  rm    rk  ri  rm  c                       \ rS rSrSrg)ImageOpenErrori  rb  Nrc  rb  ri  rj  ro  ro    rk  ri  ro  c                       \ rS rSrSrg)JpegColorspaceErrori  rb  Nrc  rb  ri  rj  rq  rq    rk  ri  rq  c                       \ rS rSrSrg)PdfTooLargeErrori  rb  Nrc  rb  ri  rj  rs  rs    rk  ri  rs  c                       \ rS rSrSrg)AlphaChannelErrori  rb  Nrc  rb  ri  rj  ru  ru    rk  ri  ru  c                       \ rS rSrSrg)ExifOrientationErrori  rb  Nrc  rb  ri  rj  rw  rw    rk  ri  rw  c                       \ rS rSrS r\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rS	 rS
 rS rSrg)jp2i  c                     Xl         g Ndata)selfr}  s     rj  __init__jp2.__init__  s    	ri  c                     [         R                  " SXUS-    5      S   nXS-   US-    nSnUS:X  a$  [         R                  " SXS-   US-    5      S   nSnUS:X  a  X!-
  nX-   nXU-   U nX4Xg4$ )N>Ir   r   rp   r   z>Qrh   structunpack)r}  	byteStartnoBytesboxLengthValueboxTypecontentsStartOffsetbyteEndboxContentss           rj  getBox
jp2.getBox  s    tTi!m-LMaP1}y1}5Q#]]4!miRTn1UVN #%Q$0N,'::WE>>ri  c                 J    [         R                  " SU S S 5      u  pp4X!X4S-   4$ )Nz>IIHBr0  r   r  )r}  heightwidthchannelsbpps        rj  
parse_ihdrjp2.parse_ihdr  s,    '-}}Wd3Bi'H$xha//ri  c                     [         R                  " SU SS 5      S   nUS:w  a  [        S5      e[         R                  " SU SS  5      S   nUS:X  a  gUS	:X  a  g
[        SU-  5      e)Nz>Br   r   z&only enumerated color method supportedr  r   rh   RGBr   Lz8only sRGB and greyscale color space is supported, got %d)r  r  	Exception)r}  methenumCSs      rj  
parse_colrjp2.parse_colr  su    }}T4!9-a019DEEtT!"X.q1R<r\MPVV ri  c                 ~    [         R                  " SU 5      u  pp4pVX-  SU-  -  S-  S-  nX4-  SU-  -  S-  S-  nXx4$ )Nz>HHHHBBr   r   RQ@r  )	r}  hnumhdenvnumvdenhexpvexphdpivdpis	            rj  
parse_rescjp2.parse_resc  sU    -3]]9d-K*DT*S0D8T*S0D8zri  c                     Su  p[        U 5      nSnSnXC:  aM  US:w  aG  [        R                  XU5      u  pVpxUS:X  a  [        R                  U5      u  p X4$ XC:  a  US:w  a  MG  X4$ )NNNr   r   s   resc)lenry  r  r  )	r}  r  r  r  r  r  r  r  r  s	            rj  	parse_resjp2.parse_res  s    
d)	!n&9<?JJ=9NW '! ^^K8
z !n&9 zri  c                 P   Su  pp4n[        U 5      nSnSnXv:  a  US:w  a  [        R                  XU5      u  ppU	S:X  a  [        R                  U5      u  ppO9U	S:X  a  [        R	                  U5      nOU	S:X  a  [        R                  U5      u  pEU
nXv:  a  US:w  a  M  XX4UWW4$ )NNNNNNr   r   s   ihdrs   colrs   res )r  ry  r  r  r  r  )r}  r  r  
colorspacer  r  r  r  r  r  r  r  r  r  s                 rj  
parse_jp2hjp2.parse_jp2h  s    0L-zd)	!n&9<?JJ=9NW '!/2~~k/J,xG# ^^K8
G# ]];7
I !n&9 zxEEri  c                 v   [        U R                  5      nSnSnSu  pEpgnX!:  aY  US:w  aS  [        R                  U R                  X!5      u  p9pU	S:X  a  [        R	                  U5      u  pEpgpnOU
nX!:  a  US:w  a  MS  U(       d  [        S5      eU(       d  [        S5      eU(       d  [        S5      eXEXgUWW4$ )Nr   r   r  s   jp2hzno width in jp2 headerzno height in jp2 headerzno colorspace in jp2 header)r  r}  ry  r  r  r  )r~  r  r  r  r  r  r  r  r  r  r  r  r  r  s                 rj  parsejp2jp2.parsejp2	  s    dii.	0L-z!n&9<?JJ		9=9NW '!GJ~~HDz I !n&9 4555669::zxEEri  c                 J   [         R                  " SU R                  SS 5      u  pp4pV      pxS /U-  n	S /U-  n
S /U-  n[        U5       H@  n[         R                  " SU R                  SSU-  -   SSUS-   -  -    5      u  X'   X'   X'   MB     U	/ SQ:X  d   eX5-
  XF-
  S S S US4$ )	Nz>HHIIIIIIIIHr   r   BBBr   r   )r@  r@  r@  rp   )r  r  r}  range)r~  lsizrsizxsizysizxosizyosiz_csizssizxrsizyrsizis                rj  parsej2kjp2.parsej2k!  s    AGDIIaOB
>DaAq v}tA*0--tyya!eb1A;.>?+'DGUXux  y   |T\4tT1DDri  c                 h    U R                   S S S:X  a  U R                  5       $ U R                  5       $ )Nr   s   OQ)r}  r  r  r~  s    rj  parse	jp2.parse/  s-    99Ra=//==?"==?"ri  r|  N)rd  re  rf  rg  r  staticmethodr  r  r  r  r  r  r  r  r  rh  rb  ri  rj  ry  ry    s     ? ? 0 0       F F$F0E#ri  ry  c                   &    \ rS rSrS rS rS rSrg)	temp_attri7  c                 (    Xl         X l        X0l        g r{  )objfieldvalue)r~  r  r  r  s       rj  r  temp_attr.__init__8  s    

ri  c                    SU l         [        U R                  U R                  5      (       a,  SU l         [	        U R                  U R                  5      U l        [        R                  SU R                   SU R                   SU R                   35        [        U R                  U R                  U R                  5        g )NFTzsetting .z = )
existshasattrr  r  getattr	old_valueloggerdebugr  setattrr  s    rj  	__enter__temp_attr.__enter__=  s~    488TZZ((DK$TXXtzz:DNxz4::,c$**FG$**djj1ri  c                     U R                   (       a,  [        U R                  U R                  U R                  5        g [        U R                  U R                  5        g r{  )r  r  r  r  r  delattr)r~  exctypeexcinstexctbs       rj  __exit__temp_attr.__exit__E  s3    ;;DHHdjj$..9DHHdjj)ri  )r  r  r  r  r  N)rd  re  rf  rg  r  r  r  rh  rb  ri  rj  r  r  7  s    
2*ri  r  c                     U $ r{  rb  )strings    rj  my_convert_loadr  M  s    Mri  c                 F   [        U 5      [        L am  SSR                  [        U R	                  5       5       VVs/ s H"  u  p#SU-  S-  U-   S-   [        X1S-   5      -   PM$     snn5      -   S-   SUS-
  -  S-  -   S-   $ [        U 5      [        L a  [        U 5      R                  5       $ [        U 5      [        L aE  [        U 5      U :X  a  [        [        U 5      5      $ SU -  R                  S5      R                  5       $ [        U [        5      (       aD  [        U S	5      (       a  S
U R                  -  R                  5       $ [        U R                  U5      $ [        U 5      [        L d  [        U [         5      (       a4  [        U 5      [        L a   [        U 5      [         La  [#        SU -  5      eU $ [        U [$        5      (       a1  SSR                  U  Vs/ s H  n[        XA5      PM     sn5      -   S-   $ [#        S[        U 5      < SU < 35      es  snnf s  snf )Ns   <<
   
r       r   s   >>z%0.4f0
identifierz%d 0 Rz3parse must be passed a bytes object in py3. Got: %ss   [ s    ]zcannot handle type z with content )typedictjoinsorteditemsr  intstrencodefloatrstrip
isinstance	MyPdfDictr  r  contentbytes	TypeErrorlist)contindentkvcs        rj  r  r  Q  s   DzTjj !'tzz| 4 4 J%)D05QJ3GG 4  6A:%& 		
 
ds	4y!!	du	t9T##dN**3/6688	D)	$	$ 4&&t.6688v..	ds	ju55:d5!8EL  	D$		tyyD!ADq%"2D!ABBUJJ4:tTUUA< "Bs   )HH
c                   2    \ rS rSrS rS rS rS rS rSr	g)	r  iy  c                 ~   [        5       U l        U(       a/  [        U5      S:X  a  US   nU R                  R                  U5        S U l        UR                  5        H]  u  p4US:X  a.  X@l        [        U5      U R                  [        R                  '   M9  US:X  a  MA  X@R                  [        [        U5      '   M_     g )Nr   r   streamindirect)	r  r  r  updater  r  	MyPdfNameLengthr  )r~  argskwkeyr  s        rj  r  MyPdfDict.__init__z  s    v4yA~AwLL%((*JCh#14UY--.
"8=WY45 %ri  c                    U R                   bF  SU R                  -  R                  5       [        U R                  5      -   S-   U R                   -   S-   $ SU R                  -  R                  5       [        U R                  5      -   S-   $ )Nz	%d 0 obj
s   
stream
s   
endstream
endobj
s   
endobj
)r  r  r  r  r  r  s    rj  tostringMyPdfDict.tostring  s    ;;"/779%&  ++ +	+ /779%& ri  c                      X R                   U'   g r{  r  )r~  r  r  s      rj  __setitem__MyPdfDict.__setitem__  s    !Sri  c                      U R                   U   $ r{  r  r~  r  s     rj  __getitem__MyPdfDict.__getitem__  s    ||C  ri  c                     XR                   ;   $ r{  r  r  s     rj  __contains__MyPdfDict.__contains__  s    ll""ri  )r  r  N)
rd  re  rf  rg  r  r  r  r  r  rh  rb  ri  rj  r  r  y  s    >  "!#ri  r  c                       \ rS rSrS rSrg)r  i  c                 *    SUR                  S5      -   $ )N   /asciir  )r~  names     rj  __getattr__MyPdfName.__getattr__  s    dkk'***ri  rb  N)rd  re  rf  rg  r"  rh  rb  ri  rj  r  r    s    +ri  r  c                       \ rS rSrS rSrg)MyPdfObjecti  c                 J    [         R                  XR                  S5      5      $ )Nr  )r  __new__r  )clsr  s     rj  r'  MyPdfObject.__new__  s    }}S--"899ri  rb  N)rd  re  rf  rg  r'  rh  rb  ri  rj  r%  r%    s    :ri  r%  c                       \ rS rSrSrg)
MyPdfArrayi  rb  Nrc  rb  ri  rj  r+  r+    rk  ri  r+  c                   0    \ rS rSrS rS rSS jrS rSrg)	MyPdfWriteri  c                     / U l         [        [        R                  / SS9U l        [        U R                  [        R
                  S9U l        / U l        g )Nr   )TypeKidsCount)Pagesr/  )objectsr  r  r2  pagesCatalogcatalog	pagearrayr  s    rj  r  MyPdfWriter.__init__  s>     IOO"AF
 tzz	8I8IJri  c                 v    [        U R                  5      S-   nX!l        U R                  R                  U5        g )Nr   )r  r3  r  append)r~  r  newids      rj  addobjMyPdfWriter.addobj  s,    DLL!A%C ri  Nc                    [        5       nSU-  R                  S5      nUS-  nUR                  U5        [        U5      nUR	                  S5        U R
                   HT  nUR	                  SU-  R                  5       5        UR                  5       n	UR                  U	5        U[        U	5      -  nMV     Un
UR                  S5        UR                  S[        U5      -  R                  5       5        U H  nUR                  U5        M     UR                  S5        [        U5      XR                  S	.nUb<  [        R                  " U5      R                  5       R                  S5      nS
X4-  US'   UR                  [        U5      S-   5        UR                  S5        UR                  SU
-  R                  5       5        UR                  S5        g )Nz	%%PDF-%s
r  s   %
s   0000000000 65535 f 
z%010d 00000 n 
s   xref
z0 %d
s   trailer
)s   /Sizes   /Infos   /Roots
   [<%s><%s>]s   /IDr  s
   startxref
z%d
s   %%EOF
)r  r  writer  r:  r3  r  r6  hashlibmd5	hexdigestr  )r~  infor  versionident	xreftable	pdfheaderposor  
xrefoffsetxtrailerrA  s                 rj  tostreamMyPdfWriter.tostream  s   F	  "G+33G<	++	Y0 )n12A036>>@AjjlGLL!3w<C	  
YhY/779:ALLO \" ^t||T++e$..077@C+sj8GFOU7^e+,^$fz)1134Z ri  c                    U R                   US'   U R                  R                  U5        U R                   R                  S   R                  U5        U R                   R                  S==   S-  ss'   U R	                  U5        g )Ns   /Parents   /Kidss   /Countr   )r4  r7  r:  r  r<  )r~  pages     rj  addpageMyPdfWriter.addpage  se    ::Zd#

8$++D1

9%*%Dri  )r6  r3  r7  r4  )1.3N)	rd  re  rf  rg  r  r<  rM  rQ  rh  rb  ri  rj  r-  r-    s    !
AFri  r-  c                   (    \ rS rSr\SS j5       rSrg)MyPdfStringi  c                 4   U(       a  SSR                  S U 5       5      -   S-   $  UR                  S5      nUR                  SS	5      nUR                  S
S5      nUR                  SS5      nS
U-   S-   $ ! [         a    SUR                  S5      -   n N^f = f)Ns   < r  c              3   J   #    U  H  nS U-  R                  S5      v   M     g7f)z%06xr  Nr   ).0r  s     rj  	<genexpr>%MyPdfString.encode.<locals>.<genexpr>  s"     !O16A:"5"5g">">s   !#s    >r  s   z	utf-16-be   \s   \\   (s   \(   )s   \))r  r  UnicodeEncodeErrorreplace)r(  r  hextypes      rj  r  MyPdfString.encode  s    		!O!OOORWWBw/ ^^E73F^^D&1F^^D&1F&=4'' & B$v}}['AABs   A6 6BBrb  N)F)rd  re  rf  rg  classmethodr  rh  rb  ri  rj  rU  rU    s    ( (ri  rU  c                       \ rS rSr\R
                  SSSSSSSSSSSSSSSSSS4S jr          SS jrS rS r	S	 r
S
rg)pdfdoci$  rS  NFc                    UcH  [         (       a  [        R                  nO,[        (       a  [        R                  nO[        R
                  nU[        R                  :X  a1  [        R                  n[        R                  n[        R                  nO\U[        R                  :X  a  SSKJ	nJ
nJnJn  O;U[        R
                  :X  a  [        n[        n[        n[         nO[#        SU-  5      eU" 5       U l        U[        R                  :w  a  U" SS9U R$                  l        S nS Hq  n[)        5       UR+                  5          nUb  US:X  a  M)  U[        R                  :w  a  WR-                  U5      nUU R$                  R&                  [/        UU5      '   Ms     [0        R2                  " 5       R5                  5       nS	 H  n[)        5       UR+                  5          nUc	  U(       a  M*  Uc  UnS
U" U5      -   R-                  S5      nU[        R
                  :X  a  SU-   S-   nUU R$                  R&                  [/        UU5      '   M     U
b  U[        R                  :X  a3  SR7                  U
5      U R$                  R&                  UR8                  '   OAWR-                  SR7                  U
5      5      U R$                  R&                  UR8                  '   S nSUb  SUR-                  S5      -  OSUc	  U(       a  SOSU" Uc  UOU5      R-                  S5      -  Uc	  U(       a  SOSU" Uc  UOU5      R-                  S5      -  4-  U l        U[        R                  :w  a  U[        R
                  :X  a  U R$                  R=                  U R$                  R&                  5        U R$                  R=                  U R$                  R>                  5        U R$                  R=                  U R$                  R@                  5        Xl!        Xl"        Xl#        Xl$        UU l%        UU l&        UU l'        Xl(        X l)        UU l*        g )Nr   )	PdfWriterPdfDictPdfName	PdfStringunknown engine: %sTr  c                 Z    U R                  [        R                  S9R                  S5      $ )Ntzz%Y%m%d%H%M%SZ
astimezoner   utcstrftimedts    rj  datetime_to_pdfdate,pdfdoc.__init__.<locals>.datetime_to_pdfdateU  s"    ==HLL=1::?KKri  )TitleAuthorCreatorProducerSubject )CreationDateModDatezD:r  r\  r]  ,c                 Z    U R                  [        R                  S9R                  S5      $ )Nrm  z%Y-%m-%dT%H:%M:%SZro  rs  s    rj  datetime_to_xmpdate,pdfdoc.__init__.<locals>.datetime_to_xmpdates  s#    ==HLL=1::;OPPri  sQ  <?xpacket begin='﻿' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>
  <rdf:Description rdf:about='' xmlns:pdf='http://ns.adobe.com/pdf/1.3/'%s/>
  <rdf:Description rdf:about='' xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
    %s
    %s
  </rdf:Description>
  <rdf:Description rdf:about='' xmlns:pdfaid='http://www.aiim.org/pdfa/ns/id/' pdfaid:part='1' pdfaid:conformance='B'/>
</rdf:RDF>
</x:xmpmeta>

<?xpacket end='w'?>
s    pdf:Producer='%s'ri  s#   <xmp:ModifyDate>%s</xmp:ModifyDate>s#   <xmp:CreateDate>%s</xmp:CreateDate>)+have_pikepdfrU   pikepdf
have_pdfrwpdfrwinternalnew
DictionaryNamerf  rg  rh  ri  r-  r  r  rU  
ValueErrorwriterdocinfolocalslowerr  r  r
   nowrp  r  Keywordsxmpr<  r6  r4  panesinitial_pagemagnificationpage_layout
fit_windowcenter_window
fullscreenengineoutput_versionpdfa)r~  r  rD  titleauthorcreatorproducercreationdatemoddatesubjectkeywordsnodater  r  r  r  r  r  r  r  rf  rg  rh  ri  ru  r   r  r  r  s                                rj  r  pdfdoc.__init__%  ss   , >|V^^#I((GllGv||#DDv&#IGG#I1F:;;kV^^#")4"8DKK	L GA#AyAG'$$Q'78DKK 34 G lln''),A#AyVy+A..66w?A(1HtO78DKK 34 - '8;8J##G$4$458A8H8HHHX&9##G$4$45	Q  ' &(@@  'F ;%'/C\&/" ?v ;%W_c'JQQ#
#
J V^^# (""4;;#6#67""4;;#6#67""4;;#4#45
(*&$*$%	ri  c                    U[         R                  [         R                  4;  d-  U[        R                  :X  a  Uc  U[        R
                  :X  d   eU R                  [        R                  :X  a1  [        R                  n[        R                  n[        R                  nOU R                  [        R                  :X  a  SSKJnJnJnJn  SSKJn  OUU R                  [        R&                  :X  a  [(        n[*        n[,        n[.        n[0        nO[3        SU R                  -  5      eU R                  [        R                  :X  a  SOW" S5      nU R                  [        R                  :X  a  SOW" S5      nU[         S	   :X  d(  U[         R4                  :X  d  U[         R                  :X  a  UR6                  nGOU[         R8                  :X  d  U[         R                  :X  a:  U[         R                  :X  a  U[        R
                  :X  a  S nGOFUR:                  nGO8U[         R<                  :X  d  U[         S
   :X  a  UR>                  nGO	U[         R@                  :X  a  U R                  [        R                  :X  a  [C        S5      e[E        U5      S-  S:X  d   eURF                  UR:                  [E        U5      S-  S-
  U R                  [        R                  :X  a  [I        U5      ONWRK                  [M        S[E        U5      S5       V s/ s H  n [N        RQ                  UU U S-    S5      PM!     sn SS9/nO[S        SURT                  -  5      eUGb0  U R                  [        R                  :X  a  U RV                  RY                  U5      n!OU" W" U5      S9n!UU!URZ                  '   U[         S	   :X  d(  U[         R4                  :X  d  U[         R                  :X  a  SU!UR\                  '   OU[         R8                  :X  d  U[         R                  :X  a  SU!UR\                  '   OPU[         R<                  :X  d  U[         S
   :X  a  SU!UR\                  '   OU[         R@                  :X  a  [C        S5      eUR^                  U!/nU[        R`                  L a  URb                  n"OU[        R
                  L a  URd                  n"SU l3        OdU[        Rh                  L a  URj                  /n"OCU[        Rl                  L a$  URn                  n"U Rf                  S:  a  SU l3        OURp                  n"U R                  [        R                  :X  a  U RV                  RY                  U5      n#OU" W" U5      S9n#URr                  U#URt                  '   URv                  U#URx                  '   U"U#URz                  '   UU#UR|                  '   UU#UR~                  '   Ub  UU#UR                  '   UU#UR                  '   S n$U[         S
   :X  a  / SQU#UR                  '   U[        Rh                  L al  U" 5       n%SU%UR                  '   U(       a  UU%UR                  '   OUU%UR                  '   UU%UR                  '   UU%UR                  '   U%/U#UR                  '   GOU[        R                  L Ga  UGbO  U R                  [        R                  :X  a  U RV                  RY                  U5      n$OU" W" U5      S9n$URr                  U$URt                  '   URv                  U$URx                  '   URp                  U$URz                  '   UU$UR|                  '   UU$UR~                  '   UR6                  U$UR                  '   UU$UR                  '   U" 5       n%SU%UR                  '   SU%UR                  '   UU%UR                  '   UU%UR                  '   U%U$UR                  '   U$U#UR                  '   U Rf                  S:  a  SU l3        U" 5       n%SU%UR                  '   U[         R@                  [         S	   [         R4                  [         R                  4;   a  SU%UR                  '   OSU%UR                  '   UU%UR                  '   UU%UR                  '   U%U#UR                  '   SXxX4-  RK                  S5      n&U R                  [        R                  :X  a  U RV                  RY                  U&5      n'OU" W" U&5      S9n'U" U" U#S9S9n(U R                  [        R                  :X  a  U RV                  R                  X4S9n)O1U" SS9n)UR                  U)URt                  '   SSX/U)UR                  '   Ub%  US   US   UUS   -
  UUS   -
  /U)UR                  '   Uc-  UR                  U);   a  U)UR                     U)UR                  '   O%US   US   UUS   -
  UUS   -
  /U)UR                  '   Uc-  UR                  U);   a  U)UR                     U)UR                  '   O%US   US   UUS   -
  UUS   -
  /U)UR                  '   Uc-  UR                  U);   a  U)UR                     U)UR                  '   O%US   US   UUS   -
  UUS   -
  /U)UR                  '   U(U)UR                  '   U'U)UR                  '   US:w  a  UU)UR                  '   Ub&  U Rf                  S:  a  SU l3        UU)UR                  '   U R                  [        R                  :w  a  U RV                  R                  U)5        U R                  [        R&                  :X  at  U RV                  R                  U'5        U RV                  R                  U#5        U$b  U RV                  R                  U$5        Ub  U RV                  R                  W!5        g g g g s  sn f ) Nr   )rg  rh  	PdfObjectri  convert_loadrj  TtrueFfalse1CMYK;Izmpdfrw does not support hex strings for palette image input, re-run with --engine=internal or --engine=pikepdfr   r   big)r`  zunsupported color space: %sr  r   z+Cannot have Palette images with ICC profile1.5z1.4)r   r   r   r   r   r   r   r   rP  z*q
%0.4f 0 0 %0.4f %0.4f %0.4f cm
/Im0 Do
Qr  )Im0)XObject)	page_sizerk  z1.6)XrY   RGBALArZ   PNGJPEG2000r  rU   r  Arrayr  r  r  rg  rh  r  ri  pdfrw.py23_diffsr  r  r  r  r%  rU  r  r  r  
DeviceGrayr  	DeviceRGBCMYK
DeviceCMYKPr  r  Indexedr  r  r  r  
from_bytesrm  r!  r  make_stream	AlternateNICCBasedJPEG	DCTDecode	JPXDecoder  CCITTGroup4CCITTFaxDecodeJBIG2JBIG2DecodeFlateDecoder  r/  r   SubtypeFilterWidthHeight
ColorSpaceBitsPerComponentDecodeKBlackIs1ColumnsRowsDecodeParms	PredictorColorsSMaskadd_blank_pagePageMediaBoxCropBoxBleedBoxTrimBoxArtBox	ResourcesContentsRotateUserUnitrQ  r<  )*r~  color
imgwidthpximgheightpx	imgformatimgdata	smaskdataimgwidthpdfimgheightpdfimgxpdfimgypdf	pagewidth
pageheightuserunitpaletteinverteddepthrotate
cropborderbleedborder
trimborder	artbordericcpPdfArrayrg  rh  r  ri  r  
TrueObjectFalseObjectr  r  iccpdictofilterimagesmaskdecodeparmstextr  	resourcesrP  s*                                             rj  add_imagepagepdfdoc.add_imagepage  s0
   4 *//:==99[__,1FK000	
1
 ;;&..(}}H((GllG[[FLL(DD5[[FOO+GG#I#I*L1DKK?@@![[FNN:T	&@Q
#{{fnn<e)GBTJsO#u
'<@V ++Jjnn$(@
'I9M9M,M "
$..
joo%*X2F)F ++Jjll"{{fll*  < 
 w<!#q(((!!W"a' {{fnn4 'N")) &+1c'lA%>%>  NN71q1u+=uE%> !% * J" --JUZZ-WXX{{fnn,;;2248",t*<=*4HW&&'C(JLL(JMM)&'#*..(EZ__,D&'#*//)Uj6J-J&'#*,,& MNN!**H5J (((''G+...''G"'D+111--.G++++))G""U*&+#))G;;&..(KK++G4E<#89E%oogll!(goo 'gnn)gmm +gnn!(2E'$$%*/g&&'Jx(($<E'..!///!)K &(K		"0;G,,-0:G,,-+5K((3K%*5E'%%&+//)$;;&..0 KK33I>E#<	+BCE&-oogll#)0goo&(/(;(;gnn%'1gmm$(3gnn%,3,>,>g(()27g../%i13G--../GNN+/9GOO,8=G445-8g))*',gmm$ &&.*/D'!)K-/K))*z#
jmmTT./GNN+./GNN++5K(49K001)4E'%%& <';<
&/ 	
 ;;&..(kk--d3G\$%78GG$67	;;&..(;;--8O-PDD)D!(D&'I%BD!!" !11JqM)Z]*	%D! $&)-goo)>W%%& AAKN*[^+	&D!!" $&(,W__(=W__% 11JqM)Z]*	%D! $&'+GOO'<W^^$ !!IaL(Yq\)	$D  #,W!(WQ;#)D ""U*&+#%-D!!";;&..(KK%{{foo-""7+""5)$KK&&u-#KK&&x0 $ . )ss   &n<c                 X    [        5       nU R                  U5        UR                  5       $ r{  )r   rM  getvalue)r~  r  s     rj  r  pdfdoc.tostring  s"    f  ri  c                 h   U R                   [        R                  :X  a1  [        R                  n[        R                  n[        R
                  nOU R                   [        R                  :X  a  SSKJnJnJ	nJ
n  SSKJn  OUU R                   [        R                  :X  a  [        n[        n[         n["        n[$        nO['        SU R                   -  5      eU R                   [        R                  :X  a  S OW" S5      nU R                   [        R                  :X  a  SOW" S5      nU R                   [        R                  :X  a  U R(                  R*                  nOU R                   [        R                  :X  a!  U R(                  R,                  R*                  nOMU R                   [        R                  :X  a  U R(                  R.                  nO['        SU R                   -  5      eU R0                  (       d/  U R2                  (       d  U R4                  (       d  U R6                  b  U" 5       XR8                  '   U R0                  (       a%  UR:                  XR8                     UR<                  '   U R6                  [>        R@                  :X  a>  URB                  XR8                     UR<                  '   URB                  XR>                  '   OU R6                  [>        RD                  :X  a>  URF                  XR8                     UR<                  '   URF                  XR>                  '   O9U R6                  [>        RH                  S 4;   a  O['        SU R6                  -  5      eU R2                  (       a  XxUR8                     URJ                  '   U R4                  (       a  XxUR8                     URL                  '   U R0                  (       a  URN                  XR>                  '   U R                   [        R                  :X  a  U R(                  RP                  S   n	OU R(                  RR                  S   n	U RT                  b  U R                   [        R                  :X  a'  U R(                  RP                  U RT                  S	-
     n	O&U R(                  RR                  U RT                  S	-
     n	U" XRV                  XfS/5      XRX                  '   U R                   [        R                  :X  a`  [[        U	[        R\                  5      (       a&  U R(                  R_                  U	R`                  5      n	OU R(                  R_                  U	5      n	U Rb                  [d        Rf                  :X  a!  U" XRh                  /5      XRX                  '   GO2U Rb                  [d        Rj                  :X  a2  XRl                     S
   n
U" XRn                  U
/5      XRX                  '   OU Rb                  [d        Rp                  :X  aS  [s        XRt                     Rv                  Ry                  5       S   5      nU" XRz                  U/5      XRX                  '   Oq[[        U Rb                  [r        5      (       a,  U" XRV                  XfU Rb                  /5      XRX                  '   O&U Rb                  c  O['        SU Rb                  -  5      eU R|                  [~        R                  :X  a  UR                  XR~                  '   GOhU R|                  [~        R                  :X  a  UR                  XR~                  '   GO0U R|                  [~        R                  :X  a  UR                  XR~                  '   OU R|                  [~        R                  :X  a  UR                  XR~                  '   OU R|                  [~        R                  :X  a0  UR                  XR~                  '   U R                  S:  a  SU lJ        OtU R|                  [~        R                  :X  a0  UR                  XR~                  '   U R                  S:  a  SU lJ        O&U R|                  c  O['        SU R|                  -  5      eU R                  Gb8  U R                   [        R                  :X  a&  U R(                  R                  U R                  5      nOFU" W" U R                  5      S9nUR                  XR                  '   UR                  XR                  '   [        U R                  S5       nUR                  5       nS S S 5        U" 5       nU R                   [        R                  :X  a-  U R(                  R                  W5      nSUR                  lW        OHU" W" [        R                  " W5      5      S9nSUUR                  '   UR                  UUR                  '   UR                  XR                  '   UR                  XR                  '   U R                   [        R                  :X  a  SOSXR                  '   UXR                  '   U" U/5      XR                  '   XUR                  '   U R                   [        R                  :X  a7  U R(                  R                  U5        U R(                  R                  U5        g g g ! , (       d  f       GN= f)Nr   )rg  rh  r  r  r  rj  nullTr  zunknown page mode: %sr   r   r   zunknown magnification: %sr  zunknown page layout: %sr  rbr   s   sRGBs   (sRGB))cr  rU   r  r  r  r  r  rg  rh  r  r  r  r  r  r  r  r%  r+  r  r  r  RootrL  r6  r  r  r  r  ViewerPreferencesUseNoneNonFullScreenPageModer[   thumbs	UseThumbsoutlinesUseOutlinesnone	FitWindowCenterWindow
FullScreenr4  r7  r  XYZ
OpenActionr  r  make_indirectr  r  r]   fitFitfithr  FitHfitbhr  r  r  splitFitBHr  r\   single
SinglePage	onecolumn	OneColumntwocolumnrightTwoColumnRighttwocolumnleftTwoColumnLefttwopagerightTwoPageRightr  twopageleftTwoPageLeftr  r  r  XMLr  Metadatar/  openreadstream_dictr  zlibcompressr  r  	GTS_PDFA1SOutputIntentOutputConditionIdentifierDestOutputProfileOutputIntentsr<  )r~  r  rg  rh  r  r  
NullObjectr   r6  r  r  imgwidthmetadataficcintents	iccstreams                    rj  finalizepdfdoc.finalize  s   ;;&..(}}H((GllG[[FLL(CC5[[FOO+GG#I!H*L1DKK?@@![[FNN:T	&@Q
![[FNN:T	&@Q
 ;;&..(kk&&G[[FLL(kk))..G[[FOO+kk))G1DKK?@@ OO!!zz%18G--.??  --.-- ::( !! --.-- )0(9(9G$$%ZZ8,,, ## --.-- )0(;(;G$$%ZZHMM4004tzzABB??DNG--.w/@/@AGQG--.w/C/CD??(/(:(:G$$%  ;;&..(;;,,Q/L;;003L
 ({{fnn,#{{001B1BQ1FG#{{44T5F5F5JK*2{{JAF+G&&' ;;&..(,55#{{889I9IJ#{{88F!2!22*2L++3N*OG&&'=#5#55$%5%56q9I*2||Y7+G&&' =#6#66\*:*:;BBHHJ1MNH*2}}h7+G&&' **E22*2{{JDDVDVW+G&&' '84;M;MMNNz000*1*<*<G&&'!5!55*1*;*;G&&'!:!::*1*@*@G&&'!9!99*1*?*?G&&'!8!88*1*>*>G&&'""U*&+#!7!77*1*=*=G&&'""U*&+#%69I9IIJJ99 {{fnn,;;22488<",txx*@A,3KK))0)9)9&dii&!ffh 'iG{{fnn, KK33C8	*+	%%'#<c8J+KL	'(	'))$,3,?,?	'..)!(!2!2GII$+$8$8GLL!;;&..8i 556 2;G--.-5wi-@G))*(0G$$%{{foo-""8,""9- .5 ! '&s   	j""
j1c                    U R                   [        R                  :X  aF  0 n[        R                  S:  a  SUS'   U R                  R
                  " U4U R                  SS.UD6  g U R                   [        R                  :X  a  SSKJnJ	n  U R                  R                  U R                  R                  l        U R                  U R                  l        U R                  (       a]  [        R                   " S5      R#                  5       R%                  S5      nU" XU/5      U R                  R                  UR&                  '   U R                  R)                  U5        g U R                   [        R*                  :X  aL  U R                  R-                  U R                  R                  UU R                  U R                  c  S OS5        g [/        S	U R                   -  5      e)
Nz6.2.0Tdeterministic_id)min_version	linearizer   )rh  r  ri  r  rj  )r  rU   r  __version__r  saver  r  rh  r  r  rL  InforD  r  r@  rA  rB  r  IDr?  r  rM  r  )r~  outputstreamkwargsrh  r  rA  s         rj  rM  pdfdoc.tostream  s^    ;;&..(F""g--1)*KK*.*=*=QW [[FLL(/'+{{':':DKK$ #'"5"5DKKyykk#&00299'B2:C:2F##GJJ/KKl+[[FOO+KK  ####		)s	 1DKK?@@ri  )r  r  r  r  r  r  r  r  r  r  r  r  )
NNFr   r   NNNNN)rd  re  rf  rg  rU   r  r  r	  r  rG  rM  rh  rb  ri  rj  rd  rd  $  s     )Gn /Q1f!
~.@Ari  rd  c                    U R                   R                  S5      nUc  U[        R                  :X  a  U R                   R                  S5      bg  U R                   S   S   S:w  aQ  U R                   S   S   S:w  a;  U R                   S   nUS   US   :  a  X$S   -  US   -  U4nOX"US   -  US   -  4nOX"4n[	        [        US   5      5      [	        [        US   5      5      4nUS:X  a  X"4nUS:X  ah  U[        R                  :X  aT  U R                  R                  [        R                  U5      U R                  R                  [        R                  U5      4nU$ )Ndpiaspectr   r   r   r   )r   r   )rC  getrZ   r  r  roundTIFFtag_v2r   X_RESOLUTIONY_RESOLUTION)r  r  default_dpindpirV  s        rj  pil_get_dpir`    sS   <<E"D| (  *6X&q)Q.X&q)Q.\\(+Fay6!9$#Qi/&);[I#6!9%<vay%HI-D d1gU47^!45D v~) v~){'7'77NN;;[INN;;[I

 Kri  c                    U[         R                  :X  a2  Ub/  U c,  [        U5      R                  5       u  pgppnU	c  Un	U
c  Un
X4nOU[         R                  :X  aw  [
        R                  " SUSS 5      u  pgpSnUS:X  a  Un	O US:  a  Un	O[        [        U5      U-  5      n	US:X  a  Un
O US:  a  Un
O[        [        U5      U-  5      n
X4nSnO&U R                  u  pg[        XU5      nU R                  n[        R                  " S/UQ76   U[         R                  [         R                  [         R                  4;   a  US	;   d  U b  S
U R                   ;   ap  U[         R                  :X  a[  UbX  US   nUS:  aM  [        R#                  SU-  5        [        R#                  S5        [        R#                  S5        [%        S5      eOU[         R&                  :X  a  U b  US	;   d  S
U R                   ;   a  [)        U R*                  R-                  [.        R0                  S/5      5      nUS:  aM  [        R#                  SU-  5        [        R#                  S5        [        R#                  S5        [%        S5      eO$US;   d  U b  S
U R                   ;   a  [%        S5      eSnUS [2        R4                  [2        R6                  4;   Ga  [9        U S5      (       a  U R;                  5       b  U R;                  5       n[<        R>                  R@                  RB                  nU(       a  UU;   a  UU   nUS:X  a  SnGOUS:X  a  SnGOUS:X  a  SnGOUS:X  a  SnGOUS;   a:  U[2        R6                  :X  a  [        R#                  SU5        GO[E        SU-  5      eU[2        R6                  :X  a  [        R#                  SU5        GOs[E        SU-  5      eGOc[9        U S5      (       a  U RG                  5       b  U RG                  5       RI                  5        H  u  nn[J        R,                  " UU5      S:X  d  M#  US:X  a  SnM-  US:X  a  SnM7  US:X  a  SnMA  US:X  a  SnMK  US;   a:  U[2        R6                  :X  a  [        R#                  SU5        M}  [E        SU-  5      eU[2        R6                  :X  a  [        R#                  SU5        M  [E        SU-  5      e   O[U[2        RL                  [2        S   4;   a  SnO;U[2        S    :X  a  SnO+U[2        S!   :X  a  SnOU[2        S"   :X  a  SnO[O        S#5      e[        R                  S$U5        U(       a  Un[        R                  S%U5        OS n[P         H  nURR                  U:X  d  M  UnM     Uc<  Ub.  U[         R                  :X  a  US&   S:X  a  [P        RT                  nO[W        S'5      eU[P        RX                  :X  a-  U[         RZ                  :X  a  S(U R                   ;   a	  [P        S)   n[        R                  S*URR                  5        S nU b+  S+U R                   ;   a  U R                   R-                  S+5      nUGbM  U[P        S   :X  a  U[         R&                  :X  d?  U[         R                  :X  Ga  U[P        R\                  :X  Ga  Ub  [_        U5      S   S,;   a  [`        Rb                  " U5       n[d        Rf                  " U5      nS S S 5        WRh                  Rj                  S-:X  a  URh                  Rl                  S.:X  a  URh                  Rn                  S/:X  aj  U[         R&                  :X  a  [        R#                  S05        O)U[         R                  :X  a  [        R#                  S15        [        R#                  S25        S nUb  U[P        S3   :X  az  U[         RZ                  :X  af  [`        Rb                  " U5       n[d        Rf                  " U5      nS S S 5        WRh                  Rp                  S4;  a  [        R#                  S55        S n[        R                  S6Xg5        UXUUU4$ ! , (       d  f       GNn= f! , (       d  f       Nn= f)7Nz>IIIIrx   rt   g^C@r   i  r  zinput dpi = %d x %d)r  r  transparencyrp   z.Image with transparency and a bit depth of %d.z+This is unsupported due to PIL limitations.zyIf you accept a lossy conversion, you can manually convert your images to 8 bit using `convert -depth 8` from imagemagickz.Refusing to work with multiple >8bit channels.r   )r  PAr  z5This function must not be called on images with alphagetexifr   r   r   r   i  )r   r   r   r@  zmUnsupported flipped rotation mode (%d): use --rotation=ifvalid or rotation=img2pdf.Rotation.ifvalid to ignorezInvalid rotation (%d)z\Invalid rotation (%d): use --rotation=ifvalid or rotation=img2pdf.Rotation.ifvalid to ignore_getexifOrientationr  90180270zinvalid rotrequ   rotation = %d°zinput colorspace (forced) = %sr   zunknown colorspaceadober  zinput colorspace = %sicc_profile)s      s      sRGBGIMPzGIMP built-in sRGBz:Ignoring RGB ICC profile in bilevel TIFF produced by GIMP.zAIgnoring RGB ICC profile in 2-color palette PNG produced by GIMP.z1https://gitlab.gnome.org/GNOME/gimp/-/issues/3438r  GRAYz.Ignoring non-GRAY ICC profile in Grayscale JPGzwidth x height = %dpx x %dpx)9rZ   r  ry  r  r  r  r  r  r  sizer`  moder  r  r  GIFrC  warningru  rZ  maxr[  rX  r   BITSPERSAMPLErV   autoifvalidr  rd  r   Baserf  r  rw  re  r  r	   r  r  rY   r!  r  r  r  r  r  	parse_pngior   r   ImageCmsProfileprofilemodelmanufacturerprofile_descriptionxcolor_space)r  r  r^  r  rawdatarotreqr  r  icsr  r  r  r  r_  xresyresINCH_PER_METERr  rotation	exif_dicto_keyr  tagr  r  r  rC  prfs                               rj  get_imgmetadatar    s    K(((W-@W_ CFg,BTBTBV?
DC<D<D|	k''	'.4mmGWRPR^.T+
"19DD[ DuT{^34D19DD[DuT{^34D|"),,
7{;ll
LL&.. [__koo{7K7KLL~Ngll$B 'G,?BKEqyORWWXLMU (D  	[%%%N"n&DGNN&&'D'DqcJK19NNKeSTNNHINNQ $$TUU  
$	$',, > WXXH$x'7'7887I&&7??+<+H)IMM--33EUi/ "%(A: HaZ!HaZ"HaZ"Hl*!1!11J "	 3JLQR  !1!11'>F2MOTU  Wj))g.>.>.@.L%..0668
U88C%6 z#$!#%!#&!#&,.!X%5%55"NN!N !&	 #7!NPU!V#  "X%5%55"NN+BEJ"6!QSX!Y# = 9F 
HMM8C=1	1	8D>	!	8E?	"	8E?	"())
LL"H-5u=Avv}  = #0BK1$" !566JOO#	[5E5E(E ',,&"8,,ejj9D}<||. 	*S/	!i;3C3C&C(%#'"1%IJ ZZ**1-C  KK'((F2//3GGK,,,P koo-W NNNOD 	*S/	!i;3C3C&CZZ**1-C  ;;##F3NNKLD
LL/I4[(DAAE 2 s   a/a.
a+.
a<c                    U R                   S   S:w  a  [        SU R                   S   -  5      eU R                  [        R                     nU R                  [        R
                     n[        U5      S:w  d  [        U5      S:w  a  [        S5      eXsu  nu  n[        R                  SU-  5        [        R                  SU-  5        X44$ )Ncompressiongroup4z4Image not compressed with CCITT Group 4 but with: %sr   z;Transcoding multiple strips not supported by the PDF formatzTIFF strip_offsets: %dzTIFF strip_bytes: %d)
rC  r  r[  r   STRIPOFFSETSSTRIPBYTECOUNTSr  NotImplementedErrorr  r  )imgstrip_offsetsstrip_bytesoffsetlengths        rj  ccitt_payload_location_from_pilr    s     xx(*Bhh}%&
 	
 JJ;;<M**_<<=K =Q#k"2a"7!I
 	
 )IVy
LL)F23
LL'&01>ri  c                 $  ^ ^^ [         R                  S5        [        5       n[        R                  " T R
                  T R                  T R                  5       5      nT R                  S   S-   S-  T R                  S   -  m[        [        S5      (       a,  [        [        ST5         UR                  USSS	9  S
S
S
5        OW[        R                  R                  mU UU4S jn[        [        R                  SU5         UR                  USSS	9  S
S
S
5        UR                  S5        [        R                  " U5      n[!        U5      u  pVUR                  U5        UR#                  U5      $ ! , (       d  f       Nd= f! , (       d  f       Nu= f)zBConvert the open PIL.Image imgdata to compressed CCITT Group4 dataz%Converting monochrome to CCITT Group4r   r@  rp   r   
STRIP_SIZErZ  r  )formatr  Nc                    > [         R                  TR                  S   [         R                  T/[         R                  S/0nUR                  UT" X5      5      $ )Nr   r   )r   ROWSPERSTRIPro  r  r  rX  )r~  r  	overridesr  pillow__getitem__tmp_strip_sizes      rj  r  )transcode_monochrome.<locals>.__getitem__  sQ    ,,gll1o//.1A,,qcI
 ==&7&BCCri  r  )r  r  r   r   	frombytesrp  ro  tobytesr  r   r  rN  ImageFileDirectory_v2r  seekr5  r  r6  )	r  newimgioimr  newimgr  r  r  r  s	   `      @@rj  transcode_monochromer    s:    LL89 yH 
w||W__5F	GB ll1o)a/',,q/AN--nEGGHVGB FE
 ,AAMM	D 11=+
 GGHVGB
 MM!ZZ!F4V<NFMM&==  7 FE
 
s   (E0 F0
E>
Fc                 N   SnSnSnU[        U 5      :  a  [        R                  " SXS-
  US-
   5      u  nX4-   [        U 5      :  a  [        SX4[        U 5      4-  5      eXS-
  U S:X  a
  XX3U-    -  nOXS-
  U S:X  a	  X X3U-    -  nX4-  nUS	-  nU[        U 5      :  a  M  X4$ )
Nri  rh   r  rp   r   zinvalid png: %d %d %ds   IDATs   PLTEr   )r  r  r  r  )r  pngidatr  r  ns        rj  rx  rx  &  s    GG
A
c'l
}}T7q51q5#9:53w<3qS\6JJKKq51(qq5))GUQ7*qq5))G		R c'l
 ri  a  
    [^\x00-\x20\x7f-\x9f] # the field name must not start with a control char or space
    [^=]+                 # the field name can even contain spaces
    =                     # field name and value are separated by an equal sign
    (?:
        [^\x00-\x20\x7f-\x9f{}] # either chars that are not braces and not control chars
        |{[^}]*}                # or any kind of char surrounded by braces
    )+c                    / nU R                  SS5      u  p#UR                  S5      nUR                  5       R                  S5      (       d   e0 n[	        [
        R                  " [        U5      5       GH  u  pVU(       d  M  UR                  SS5      u  pxUS:X  a,  UR                  5       S:X  d   eUR                  5       S:X  d   eUR                  5       S	:X  a  US
;   a  XS	'   Mu  [        SU5        M  UR                  5       S:X  a  US;   a  XS'   M  [        SU5        M  UR                  5       S:X  a$  US;   a  [        U5      US'   M  [        SU5        M  UR                  5       S:X  a  [        U5      US'   GM  UR                  5       S:X  a+  US:X  a  SUS'   GM0  US:X  a  SUS'   GM>  [        SU5        GMM  UR                  5       S;   a  [        U5      XGR                  5       '   GM  UR                  5       S:X  a  [        S5        GM  UR                  5       S:X  a  US;   d   eXS'   GM  UR                  5       S:X  d  GM  UR                  SS5      u  p[        U	5      [        U
5      4US'   GM     SU;   d   eS U;   d   eS!U;   d   eUS	   S":X  Ga  SU;   a  US   S:X  d   eUS   S#:X  a  S$n[        R                  nO7US   S%:X  a  S&n[        R                  nOUS   S':X  a  Sn[        R                  nUR                  S5      (       a  WS-  nUR                  S5      (       a  [        S(5        U$ US   S)-  W-  US    -  US!   -  n[!        U5      U:  d   [!        U5      US   UUS    US!   U45       eW[        R                  :X  a_  US   S):X  aV  ["        R$                  " S*US    US!   4US U 5      n['        U5      u  nnnUS+:X  d   eUUS   :X  d   e[(        R*                  nO)[,        R.                  " US U 5      n[(        R0                  nUR3                  UUR                  S5      =(       d    [4        [4        4UUS US    US!   / SUS   SS 45        [!        U5      U:  a7  X=S  S S, R                  5       S-:X  d   eUR7                  [9        X=S  5      5        U$ US	   S.:X  GaI  SU;   d   eUR                  S5      (       a  S/nOSnS$US   -  US   -  S)-  nXS!   -  US    -  n[!        U5      UU-   :  d   [!        U5      UU45       eUR3                  [        R                  UR                  S5      =(       d    [4        [4        4[(        R0                  [,        R.                  " UUUU-    5      S US    US!   US U SUS   SS 45        [!        U5      UU-   :  aP  UUU-   S  S S, R                  5       S-:X  d   [!        U5      UU45       eUR7                  [9        UUU-   S  5      5        U$ )0Ns   :r   z
ISO-8859-1zid=imagemagick=r   idimagemagickclass)DirectClassPseudoClasszcannot understand classr  )rl  r  Grayzcannot understand colorspacer  )81632zcannot understand depthcolorsmatteTrueTFalseFzcannot understand matte)columnsrowsr  zcompression not yet supportedr{  )rD  exif
resolutionrK  r  r  r  rl  r   r  r   r  z
FAIL: exifrp   r  ri  r      id=imagemagickr  r   )r%  decoder  
startswith	enumeraterefindallmiff_reprintr  r  rY   r  r  r  rX  r  r   r  to_png_datarZ   r  r8  r9  MIFFr:  r^  extend
parse_miff)r}  resultsheaderresthdatar  liner   r  dpixdpiynumchannelsr  
lenimgdatar  r  r  r  imgfmtlenpals                       rj  r  r  I  s?   G::h*LF]]<(F<<>$$%56666ERZZ89zz#q!6779$$$779--- 779 66)*g 7;WWY,&
 00./l+ <a@WWY'! ))),Qg 7;WWY(""%a&hWWY'! ;)-g'\).g 7;WWY--#&q6ggi WWY-'56WWY)#O+++#$i WWY,&WWS!_
',T{E$K&@l#C :F eU?? W~&5 X!+++ \"f,"#K!+J|$."#K!+J|$."#K!+Jyy!!q yy## l#X NS 'Na'+5i8HH5QW=X  4yJ. I'N)$&M1 . /E'Na4G"__UU95EuV}4UW[\g]gWhiF.9&.A+GWe"c>)> E'N222(__F"mmD*,=>G(--F"		,/MK3Mi(fg  t9z),Sb1779=NNNNNN:d;.?#@AF NC 
w=	(u$$$yy!!x(5>9Q>F$V}4uY7GGJt9 33Tc$i5TT3NNNNIIl+I[/I$$MM$v0C"DE)$&M&M'N  4y6J..FZ/123B7==?CTT IW T
 z$v
/B/D*EFGNri  c                 &  ^+^, [        U 5      m+T+R                  S5        S m, [        R                  " T+5      m,[        R                  ST,R                  5        [        [        T,R                  [        R                  5      nU+U,4S jn[        R                  SUR                   5        U[        R"                  :X  d  U[        R                  :X  a  [%        T,U[&        XU5      u  pppU[(        S   :X  a  [+        S5      eU[(        S   :X  a  [+        S5      eU[(        S   :X  a  U[        R                  :w  a  [+        S5      e[        R                  S5        U" 5         SnU[        R                  :X  a  [-        U 5      R/                  5       Gt pUU	UU S U
U/ SUUU4/$ U[        R0                  :X  GaZ  / nSn[3        T,R4                  5      [3        T,R6                  S   5      :X  d   e[3        T,R6                  S   5      nSnSn[9        T,R6                  S   5       H  u  nnUS:X  a:  US   S   (       a-  US   S   (       d   US   S   (       a  US   S   S :X  a  US!-  nMF  US   S   (       a  MU  US   S   (       d  Md  US   S   (       a  Ms  US   S   S";   d  M  US!-  nM     [        R                  S#U 35        [        R                  S$U 35        [        R                  S%U 35        US!:X  d  U(       d  US!:X  a  US!-   U:X  a  [%        T,U[&        XU5      u  pppU[(        S   :X  a  [+        S5      eU[(        S   :X  a  [+        S5      eU[(        S   :X  a  [+        S5      e[        R                  S&5        U" 5         UU	[        R"                  U S U
U/ SSUU4/$ [;        T,R4                  T,R6                  S   5       GH:  u  nnU(       a	  US:  a    GO([        U UUUS'   -    5       n[        R                  " U5       nUS:  a&  UR                  S(:w  a  [=        S)UR                  5      e[%        U[        R"                  [&        XS*9u  nn	n
nnnS S S 5        S S S 5        W[(        S   :X  a  [+        S5      eU[(        S   :X  a  [+        S5      eU[(        S   :X  a  [+        S5      e[        R                  S+5        UR?                  UW	[        R"                  U UUUS'   -    S W
W/ SSWW45        US!-  nGM=     U" 5         U$ U[        R@                  :X  a  U S,   S:X  a  [%        T,U[&        XU5      u  pppU[(        RB                  :w  a  U[(        RD                  :w  a  U[(        RF                  :w  ak  S-T,RH                  ;  a[  [K        U 5      u  nnU S   nUS.;  a  [M        S/U-  5      eUS0:X  d  Uc+  [        R                  S15        U" 5         UU	UUS U
UUSUUU4/$ U[        R                  :X  a+  [%        T,U[&        XU5      u  pppU S2S
 nUU	UUS U
U/ SS!UU4/$ U[        R                  :X  a  [O        U 5      $ / nSn  T,R                  U5        U(       a  US:  a  GORU[        RR                  :X  aC  [U        T,RV                  RY                  [Z        R\                  S!/5      5      S:  a  [M        S45      eU[        RR                  :X  Ga  T,RH                  S5   S6:X  Ga  [3        T,RV                  [Z        R^                     5      S!:X  Ga  [3        T,RV                  [Z        R`                     5      S!:X  Gai  T,RV                  [Z        Rb                     nSnUS:X  a  S3nOUS!:w  a  [M        S7U-  5      e[%        T,U[&        XU5      u  ppp[e        T,5      u  nnT+R                  U5        T+Rg                  U5      n T,RV                  RY                  [Z        Rh                  5      n U c  OqU S!:X  a  OjU S8:X  aV  [        R                  S95        [k        U 5      n [m        [3        U 5      5       H  n[n        U U      U U'   M     [q        U 5      n O[M        S:U -  5      e[        R                  S;5        UR?                  UU	[        Rr                  U S U
U/ US!UU45        US!-  nGMa  [        R                  S<U-  5        [%        T,U[&        XS*9u  pppS n!U[(        S   :X  aT   [u        T,5      n"[        R                  S=5        UR?                  UU	[        Rr                  U"S U
U/ SS!UU45        US!-  nGM  U[(        Rz                  [(        RB                  [(        Rx                  [(        RD                  [(        R|                  [(        S@   [(        R~                  4;   a  [        R                  SAU5        T,n!O[M        SBUR                   -  5      eU[(        R|                  [(        S@   4;   aX  [        R                  " U!R                  5       5      n#[        R                  SC5        UR?                  UU	UU#S U
U/ SSUU45        GOnU[(        R~                  [(        RF                  4;   an  Ubk  U[(        R~                  :X  a   [(        Rz                  n$U!Rw                  SDSE9n!O3U[(        RF                  :X  a  [(        RB                  n$U!Rw                  SSE9n!S n%GOU[(        RB                  :X  d9  U[(        RD                  :X  d%  U[(        RF                  :X  d  S-U!RH                  ;   Ga<  U[(        RB                  :X  a2  Un$U!R                  5       u  n&n'n(n)[        R                  " SDU&U'U(45      n!OU[(        RD                  :X  a  Un$U!R                  5       u  n*n)U*n!OU[(        RF                  :X  d$  U[(        R~                  :X  a3  S-U!RH                  ;   a#  Un$U!Rw                  SSE9R                  5       SF   n)OL[(        RB                  n$U!Rw                  SSE9R                  5       u  n&n'n(n)[        R                  " SDU&U'U(45      n![        U)5      tn%n[        R                  SG5        OUn$S n%[        U!5      u  nnn[        R                  SH5        UR?                  W$U	[        R@                  UU%U
UUSUUU45        US!-  nGMs  U" 5         U$ ! [         a  nU S S S:X  a  [        R                  n S nAGNpU S S S:X  a>  [        R                  nU S S S:w  a  [        S	5      eU S
S  S:w  a  [        S5      e S nAGNU S S R                  5       S:X  a  [        R                  n S nAGN[        SU-  5      eS nAff = f! , (       d  f       G	N(= f! , (       d  f       G	N2= f! [P         a     M  f = f! [<         aV  n[        R                  U5        [        R                  S>5        T,Rw                  S?5      n![(        Rx                  n S nAGN7S nAff = f)INr   zPIL format = %sr   s      jP  

rp   s   JB2

rx   s   JB2

       0    z^Unsupported JBIG2 format; only single-page generic coding is supported (e.g. from `jbig2enc`).is      1        3     zkUnsupported JBIG2 format; we expect end-of-page and end-of-file segments at the end (e.g. from `jbig2enc`).r   r  zDcannot read input image (not jpeg2000). PIL: error reading image: %sc                  n   > Tb   TR                  5         T R                  5         g ! [         a     Nf = fr{  )closeAttributeError)r  r  s   rj  cleanupread_images.<locals>.cleanupA  s6     	
 " s   ' 
44zimgformat = %sr  zjpeg can't be monochromer  zjpeg can't have a color paletter  z jpeg can't have an alpha channelzread_images() embeds a JPEGFi  	AttributeDependentParentImageFlagDependentChildImageFlagRepresentativeImageFlagMPTypezBaseline MP Primary Imager   )z Large Thumbnail (VGA Equivalent)z$Large Thumbnail (Full HD Equivalent)znumber of frames: znumber of main frames: znumber of thumbnail frames: z$read_images() embeds an MPO verbatimSizer  zMPO payload must be a JPEG %s)r  z$read_images() embeds a JPEG from MPOr   rb  r   r   r   rp   rh   invalid bit depth: %dri  zread_images() embeds a PNGr  Tz5PIL is unable to preserve more than 8 bits per sampler  r  z:unsupported photometric interpretation for group4 tiff: %dr   z'fillorder is lsb-to-msb => reverse bitszunsupported FillOrder: %dz%read_images() embeds Group4 from TIFFzConverting frame: %dz2read_images() encoded a B/W image as CCITT group 4zConverting colorspace 1 to Lr  r  zColorspace is OK: %sz%unknown or unsupported colorspace: %sz1read_images() encoded CMYK with flate compressionr  )rp  r  zlImage contains an alpha channel. Computing a separate soft mask (/SMask) image to store transparency in PDF.z%read_images() encoded an image as PNG)Gr   r  r   r5  r  r  r  r  rZ   otherIOErrorr  r  ro  r  r  r!  r  r  r^  rY   rq  ry  r  MPOr  _MpoImageFile__mpoffsetsmpinfor  zipr  r:  r  r  r  rc  rC  rx  r  r  EOFErrorrZ  rs  r[  rX  r   rt  r  r  PHOTOMETRIC_INTERPRETATIONr  r6  	FILLORDER	bytearrayr  TIFFBitRevTabler  r  r  convertr  r  r  r  r8  r9  r  r%  merger  rr  )-r  r  first_frame_onlyrotinclude_thumbnailsr  er  r  r_  r  r  r  r  r  r  resultimg_page_count
num_framesnum_main_framesnum_thumbnail_framesr  mpentr  rawframeimframer  r  
streamdataphotor  r  	fillorderr  	ccittdataimggznewcolor	smaskidatrgbalr  r  s-                                              @@rj  read_imagesr	    s    
	BGGAJG?L**R.z 	&7K9J9JK	 LL!9>>2 K$$$	[5I5I(I?NYZ#@
<Zh JsO#%&@AAJsO#%&GHHJv&&98L8L+L%&HII23	,,,G**,IQ 
 	
2 KOO#7334GNN6<R8SSSS/0
  !'.."89HAu Q+&'ABk*+DE+&'@A+&x04OO1$+&'ABB+&'@AAk*+DEE+&x0 %)$) :* 	)*67..?@A34H3IJK ?"1$$q(J6CRKcD@E( 
3')*DEE
3')*KLL
6**)*LMMLL?@I $$ ( !,,gnnV.D
MFE  NQ$6&5=*@ABhZZ)W &)gnn.F'(GXX (!1!1;
"#  * C" 
3')*DEE
3')*KLL
6**)*LMMLL?@MM$$FVeFm%;<  aN[
\ 		 KOO#q(8?NYZ#@
<Zh Z__$&&gll2(1GW
 BKE,, !85!@AA #~9:	 !"#  " K%%%?NYZ#@
<Zh R_
 
 	
" K$$$'"" FN
	LL(  2 )))GNN&&'D'DqcJKaOTUU
 )))]+x7GNN?#?#?@AQFGNN?#B#BCDINN?#M#MNEHz! &(-.  DSKcD@E( =WENFFGGFOggfoG**?+D+DEI aaFG#G,s7|,A!0!<GAJ -. !<y!HIILL@AMM++  aN+n<=?NYZ@
<Zh JsO#%09	QR#//!"#   !# NNOOLLMMOOx LL
 
 LL/7FDuzzQRR Z__j&:;;MM&.."23ELLLMMM" z}}55$:JJLL()~~H#^^^7Fjmm+)H#^^^8F 	(JMM)JMM)!V[[0JOO+$H!'JAq!Q"[[Aq	:Fjmm+$H!<<>DAqFjmm+Z\\)n.K$HF399;B?A)H!'V!<!B!B!DJAq!Q"[[Aq	:F +A	AM
 ! 	&1&&9#GWeLL@AMMOO  	!e f IM}  :3B<NN#,,IRa[??: $))Ivw %t  hi % B i Sb\!%66 $((I /123 o:N *) CBN  		V  %Q;< -"	%s{   s 1vAu;vv (Av0 
u8u31Au38'u3%u33u8;
v
v
v	
v-,v-0
x:Axxc                     [        5       nU R                  USS9  [        UR                  5       5      u  p#UR	                  S5        [        UR                  S5      5      nUS;  a  [        SU-  5      eX#U4$ )Npng)r  rx   r   r  r  )r   rN  rx  r  r  ordr6  r  )r  	pngbufferr  r  r  s        rj  r  r  #
  sw     	IHHYuH% !3!3!56G
 NN2	q!"E$$05899U""ri  c                     SU -  U-  $ N      R@rb  )r  rU  s     rj  px_to_ptr  7
  s    &=3ri  c                     SU -  S-  $ )Nr  r  rb  r  s    rj  cm_to_ptr  ;
      6MT!!ri  c                     SU -  S-  $ )Nr  gffffff9@rb  r  s    rj  mm_to_ptr  ?
  r  ri  c                     SU -  $ r  rb  r  s    rj  in_to_ptr  C
  s    &=ri  c                    ^ ^^^^^^ S mT c  Tc	  Tc  [         $ T c  Tc  Tb  U4S jnU$ Tc  SmT b  Tc  UUUUU 4S jnU$ S mT c  Tb  UUUUU4S jnU$ T b  Tb  UUUUU U4S jnU$ [        e)Nc                   ^^^^ Tc  Tc  [        S5      eU [        R                  [        R                  4;   a  Tb  TS:  a  Tb  TS:  a  [        S5      eU [        R                  [        R                  4;  a  Tb  TS:  d	  Tb  TS:  a  [	        S5      eUUUU4S jnU b  U [        R
                  :X  a  U" 5       $ U [        R                  :X  aT  Tb   Tb  TnUT-  T-  nUT:  a
  TnUT-  T-  nXg4$ Tc  Tb  TnUT-  T-  nXg4$ Tc  Tb  TnUT-  T-  nXg4$ [        S5      eU [        R                  :X  a;  Tb  Tb  TT4$ Tc  Tb  TnUT-  T-  nXg4$ Tc  Tb  TnUT-  T-  nXg4$ [        S5      eU [        R                  :X  aX  Tb  Tb  TT::  a
  TT::  a  TT4$ U" 5       $ Tc  Tb  TT::  a  TT4$  U" 5       $ Tc  Tb  TT::  a  TT4$  U" 5       $ [        S5      eU [        R                  :X  aY  Tb  Tb  TT:  d  TT:  a  TT4$  U" 5       $ Tc  Tb  TT:  a  TT4$  U" 5       $ Tc  Tb  TT:  a  TT4$  U" 5       $ [        S5      e[        e)N*fitwidth and fitheight cannot both be Noner   z>cannot fit into a rectangle where both dimensions are negativez@cannot fit into a rectangle where either dimensions are negativec                     > Tb   Tb  Tn U T-  T-  nUT:  a
  TnUT-  T-  n X4$ Tc  Tb  TnUT-  T-  n X4$ Tc  Tb  Tn U T-  T-  nX4$ [        S5      e)Nr  )r  )newimgwidthnewimgheight	fitheightfitwidth	imgheightrA  s     rj  default/get_layout_fun.<locals>.fitfun.<locals>.defaultb
  s    #	(=& +i 78C)+#,L#/(#:i"GK ,, !i&;(+h6)C ,, "x';& +i 78C ,, !!MNNri  )	r  rW   fillenlarger  intoexactshrinkr  )r   rA  r"  r!  r   r#  r  r  s    ````   rj  fitfunget_layout_fun.<locals>.fitfunJ
  sX   	 1IJJ
 GLL'//22$1%AP  w77!hl%)a-R 	- 	-" ;#-9GLL #	(=& +i 78C)+#,L#/(#:i"GK ,, !i&;(+h6)C ,, "x';& +i 78C ,, !!MNNGMM!#	(=**!i&;(+h6)C ,, "x';& +i 78C ,, !!MNNGNN"#	(=x'I,B#Y.. 9 !i&;	)#Y.. * 9 "x';x'#Y.. ( 9 !!MNNGOO##	(=h&)i*?#Y.. +@ 9 !i&;y(#Y.. ) 9 "x';h&#Y.. ' 9 !!MNN &%ri  c                 p   > [        XS   5      n[        XS   5      nUSTS   -  -   nUSTS   -  -   nXVX44$ Nr   r   r   r  )r  r  r_  r  r  r  r  borders          rj  
layout_fun"get_layout_fun.<locals>.layout_fun
  sN    ":Aw7K#Ka9L#a&)m3I%F1I5J+CCri  rW  c           	        > TS   bC  TS   b=  T
(       a6  X:  a  TS   TS   :  d  X:  a   TS   TS   :  a  TS   TS   pCTS   TS   4nOTS   TS   pCTnUb  USUS   -  -
  nOS nUb  USUS   -  -
  nOS nT[         R                  [         R                  4;   a  Ub  US:  a  Ub  US:  a  [        S5      eT[         R                  [         R                  4;  a  Ub  US:  d	  Ub  US:  a  [        S5      eT" T[	        XS   5      [	        XS   5      UU5      u  pUc  UTS   S-  -   nUc  U	TS   S-  -   nX4X4$ )Nr   r   r   zVat least one border dimension musts be smaller than half the respective page dimensionzIone border dimension is larger than half of the respective page dimension)rW   r%  r&  ra  r  )r  r  r_  r  r  	newborderr!  r   r  r  auto_orientr/  r   r*  pagesizes             rj  r0  r1  
  s   'QK+-(1+2K"0Xa[8A;5N )1Xa[:"1Ivay0	(0Xa[:"	$$q9Q<'77%&Yq\)99	 	goo66(qL)M,4  W\\7??;;%(Q,)i!m,0  )/!W-1g.)%K  '&)a-7	!)F1IM9
+CCri  c                     U c  g U u  p4U[         R                  :X  a  U$ U[         R                  :X  a  [        X5      U-  S-  $ U[         R                  :X  a  [        X5      $ [
        e)Nr   )r^   abspercr  rU  r  )spxrU  rp  r  s        rj  scale_imgsize%get_layout_fun.<locals>.scale_imgsize
  s`    97;;L7<<R%-447;;B&&!!ri  c                    > T	" T[        XS   5      [        XS   5      T" T
S   XS   5      T" T
S   XS   5      5      u  p4USTS   -  -   nUSTS   -  -   nXVX44$ r-  r.  )r  r  r_  r  r  r  r  r/  r   r*  imgsizer;  s          rj  r0  r1  
  s    (.!W-1g.gaj*1g>gaj+Aw?)%K $a&)m3I%F1I5J+CCri  c                   > TS   b9  TS   b3  T(       a,  X:  a  TS   TS   :  d  X:  a  TS   TS   :  a
  TS   TS   pCO	TS   TS   pCT	" T[        XS   5      [        XS   5      T" T
S   XS   5      T" T
S   XS   5      5      u  pVX4XV4$ Nr   r   r.  )r  r  r_  r  r  r  r  r4  r   r*  r>  r5  r;  s          rj  r0  r1    s    'QK+-(1+2K"0Xa[8A;5N )1Xa[:(0Xa[:(.!W-1g.gaj*1g>gaj+Aw?)%K +CCri  )default_layout_funr  )r5  r>  r/  r   r4  r0  r*  r;  s   ````` @@rj  get_layout_funrB  G
  s    b&L GO!!GO0B	D ~ 5	D 5	Dn 
" G/
	D 
	D  3	D 	D, 
ri  c                 F    [        XS   5      =p4[        XS   5      =pVXFX54$ r@  r.  )r  r  r_  r  r  r  r  s          rj  rA  rA  3  s/    &z7;;K (1g >>L+;;ri  c                    ^  U 4S jnU$ )zLayout 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=...)
c                    > [        XT5      $ r{  )rA  )r  r  r_  	fixed_dpis      rj  fixed_dpi_layout_fun6get_fixed_dpi_layout_fun.<locals>.fixed_dpi_layout_fun@  s    !*9EEri  rb  )rF  rG  s   ` rj  get_fixed_dpi_layout_funrI  9  s    F  ri  c                 T    SSK JnJn  [        X5      nUS-  nSU" U" U5      5      -  $ )a  Find the power of 10 (10, 100, 1000...) that will reduce the scale
below the PDF specification limit of 14400 PDF units (=200 inches).
In principle we could also choose a scale that is not a power of 10.
We use powers of 10 because numbers in the PDF format are represented
in base-10 and using powers of 10 will thus just shift the comma and
keep the numbers easily readable by humans as well.r   )log10ceil      @r   )mathrK  rL  rs  )r  r  rK  rL  major	oversizeds         rj  
find_scalerQ  F  s/     !	&EIeI&'''ri  c                  n   [        S00 SS _SS _SS _SS _SS _SS _SS _SS _S	S _S
S _SS_S[        _SS _SS _SS _SS _SS_SS_SS_SS_SS_SS _SS _SS _SS _SS _SS _SS_6nUR                  5        H  u  p4X1;  d  M  XAU'   M     [        US   SUS   US   US   US   US   US   US   US	   US   US   US   US   US   US   US   US   US   5      n[	        U 5      S :X  a#  [        U S!   [        [        45      (       a  U S!   n [        U [        [        45      (       d  U /n O[	        U 5      S!:X  a  [        S"5      eU  GH  nS nS# H  n [        Xh5      " 5       nM     UcS  [        U[        [        45      (       d  [        S$5      e [        US%5      n	U	R                  5       nU	R!                  5         [%        UUS
   US   US   US   5       GH  u  n
nnnnnnnnnnnUS   " UUU5      u  nnnnS nUS&:  d  US&:  a  [&        R)                  S'5        OBUS(:  d  US(:  a6  US   (       a!  [+        UU5      nUU-  nUU-  nUU-  nUU-  nO[-        S)5      eS* HN  nUUS+-      c  M  US,UUS+-      S    -  :  a  [        S-U-  5      eUS,UUS+-      S!   -  :  d  MB  [        S.U-  5      e   UU-
  S/-  nUU-
  S/-  nUR/                  U
UUUUUUUUUUUUUUUUUS   US   US   US   U5        GM"     GM     UR1                  5         U$ ! [         a     GM  f = f! ["         a    Un GNwf = f)1Nr  r  r  r  r  r  r  r  r  r  r  Fr0  viewer_panesviewer_initial_pageviewer_magnificationviewer_page_layoutviewer_fit_windowviewer_center_windowviewer_fullscreenr  allow_oversizedTr  r  r  r  r  r  r  rS  r   r   zUnable to process empty list)r6  
read_bytesz0Neither read(), read_bytes() nor is str or bytesr  g      @z?pdf width or height is below 3.00 - too small for some viewers!rM  z/pdf width or height must not exceed 200 inches.)cropbleedtrimartr/  r   z+horizontal %s border larger than page widthz*vertical %s border larger than page heightg       @rb  )r  rA  r  rd  r  r  r  tupler  r  r  r  r  r  r5  r6  r  r  r	  r  rr  rQ  rs  r	  rG  )imagesrR  _default_kwargskwnamer#  pdfr  r  funrC  r  r_  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r/  r  r  s                                 rj  convert_to_docobjectrf  Y  s      	
        &  ! "   !"  #$ #%&  '( )* +, -. /0 12 34 56 78 !9O< +002$6N 3 xwxyz~yyzx~$%%&#$"#%&"#v'C0 6{afQi$//AYFftUm,,v;!;<< 'C!#+- (
 ?cC<00 RSSdO &&(	& < %&:'(

 @Fl?SK@<Iz; H4:#4U W$
W(<+,))Z@H)I(*J8+K H,L*I  ;&8+,4q6&8*;#<Q#???$EN  F6H+<$=a$@ @@$DvM  ; !;.#5G!L0C7G|$}%|${#-S
_ b LLNJU "    	s$   LL$
L! L!$L43L4)rQ  c                 j    [        U0 UD6nU (       a  UR                  U 5        g UR                  5       $ r{  )rf  rM  r  )rQ  ra  rR  rd  s       rj  r  r    s/    

1&
1C\"<<>ri  c                 r   U S:X  a  g S nU R                  S5      (       a  [        R                  nOU R                  S5      (       a  [        R                  nOZU R                  S5      (       a  [        R                  nO3U R                  S5      (       a  [        R
                  nO [        U 5      n Uc  [        R                  nOU S S n  [        U 5      n U S	:  a  U< S
U < 3n[        R                  " U5      eU[        R                  :X  a  [        U 5      n U $ U[        R                  :X  a  [        U 5      n U $ U[        R
                  :X  a  [        U 5      n U $ ! [         a     U< SU < 3n[        R                  " U5      ef = f! [         a     U< SU < 3n[        R                  " U5      ef = f)Nr|  ptcmmmin? is not a floating point number and doesn't have a valid unit: ! is not a floating point number: r   z must not be negative: )endswithr_   ri  rj  rk  inchr  r  argparseArgumentTypeErrorr  r  r  numr!  unitmsgs       rj  	parse_numrx  #  s   
byD
||Dww	d		ww	d		ww	d		yy	2*C |ww#2h	2*C Qw/3S9((--twwsm
 J	 
sm J 
	smJ1  	2 %)#/  ,,S11	2  	2=A3GC,,S11	2s   'E F *F	*F6c                 |   U S:X  a  g S nU R                  S5      (       a  [        R                  nOU R                  S5      (       a  [        R                  nOU R                  S5      (       a  [        R                  nOU R                  S5      (       a  [        R
                  nOZU R                  S5      (       a  [        R                  nO3U R                  S5      (       a  [        R                  nO [        U 5      n Uc  [        R                  nOEU[        R                  :X  a  U S S	 n OU[        R                  :X  a  U S S
 n OU S S n  [        U 5      n U[        R                  :X  a  [        R                  [        U 5      4n U $ U[        R                  :X  a  [        R                  [        U 5      4n U $ U[        R
                  :X  a  [        R                  [!        U 5      4n U $ U[        R                  :X  a  [        R                  U 4n U $ U[        R                  :X  a  [        R                  U 4n U $ U[        R                  :X  a  [        R                  U 4n U $ ! [         a     U< SU < 3n[        R                  " U5      ef = f! [         a     U< SU < 3n[        R                  " U5      ef = f)Nr|  ri  rj  rk  rl  rU  %rm  r  rn  ro  )rp  r`   ri  rj  rk  rq  rU  r8  r  r  rr  rs  r^   r7  r  r  r  rt  s       rj  parse_imgsize_numr|  M  sE   
byD
||Dzz	d		zz	d		zz	d		||	e		{{	c		||	2*C |zz 7;;cr(CW\\!cr(Ccr(C	2*C wzz{{HSM* J 
	{{HSM* J 
	{{HSM* J 
	{{C 
 J	 
	{{C  J 
	||S!JC  	2 %)#/  ,,S11	2$  	2=A3GC,,S11	2s   5I$ J $*J*J;c                    U R                  S5      nU(       a  U S S n [        R                  U R                  5       5      (       a  [        U R                  5          n SU ;  a  [	        U S5      nS nO,U R                  SS5      u  p#[	        US5      n[	        US5      nU(       a  X2p2Uc  Uc  [        R                  " S5      eX#4$ Nz^Trn  rK  r  r   r  z(at least one dimension must be specified)rp  
papersizesrX  r  rx  r%  rr  rs  r  
transposedwhs       rj  parse_pagesize_rectargr    s    &J~~flln%%FLLN+
& fg&||C#a!a"1yQY(()STT4Kri  c                    U R                  S5      nU(       a  U S S n [        R                  U R                  5       5      (       a  [        U R                  5          n SU ;  a  [	        U S5      nS nO,U R                  SS5      u  p#[	        US5      n[	        US5      nU(       a  X2p2Uc  Uc  [        R                  " S5      eX#4$ r~  )rp  r  rX  r  r|  r%  rr  rs  r  s       rj  parse_imgsize_rectargr    s    &J~~flln%%FLLN+
& fg.||C#a)a*1yQY(()STT4Kri  c                     [          H  nUR                  U :X  d  M  Us  $    SR                  [          Vs/ s H  oR                  PM     sn5      n[        R                  " SU < SU< S35      es  snf )N, zUnsupported colorspace: . Must be one of: r  )rY   r!  r  rr  rs  r  r  alloweds      rj  parse_colorspaceargr    s^    66VH  ii4A45G

$
$=CWM  5   A0c                     [          H  nUR                  U :X  d  M  Us  $    SR                  [          Vs/ s H  oR                  PM     sn5      n[        R                  " SU < SU< S35      es  snf )Nr  zUnsupported engine: r  r  )rU   r!  r  rr  rs  r  s      rj  parse_engineargr    s^    66VH  ii0A01G

$
$9?I  1r  c                 P   SU ;   aM  U R                  SS5      u  pUS:X  a  [        R                  " S5      eUS:X  a  [        R                  " S5      eOU S:X  a  [        R                  " S5      eX p![        US5      [        US5      p!Uc  Uc  [        R                  " S	5      eX4$ )
N:r   r|  zmissing value before colonzmissing value after colonzborder option cannot be emptyzleft/right borderztop/bottom borderzmissing value)r%  rr  rs  rx  )r  r  r  s      rj  parse_borderargr    s    
f}||C#7,,-IJJ7,,-HII  R<,,-LMM1Q+,i;N.OqyQY((994Kri  c                 |   / nU S:X  a)  [         R                  R                  R                  5       nO%[	        U S5       nUR                  5       nS S S 5        WR                  S5       HC  n U S:X  a  M   [	        U S5       nUR                  S5        S S S 5        UR                  U 5        ME     U$ ! , (       d  f       Nh= f! , (       d  f       N6= f! [         a    [        R                  " SU -  5      e[         a    [        R                  " SU -  5      e[         a    [        R                  " SU -  5      ef = f)	N-r      ri  r   "%s" is a directory"%s" permission denied"%s" does not exist)sysstdinbufferr6  r5  r%  IsADirectoryErrorrr  rs  PermissionErrorFileNotFoundErrorr:  )pathr  r  rC  r  s        rj  	from_filer    s   Fs{))""'')$ffhG e$3;
	K dD!R
 " 	d % M#  "!  	K,,-BT-IJJ 	N,,-E-LMM  	K,,-BT-IJJ	Ks6   B14C CC1
B?
C	CCA(D;c                 $   U S:X  aT  [         R                  R                  R                  5       /n[	        U5      S:X  a  [
        R                  " SU -  5      e U$ / nU /n[         R                  S:X  a#  SU ;   d  SU ;   a  SSKJn  [        U" U 5      5      nU Hw  n [        R                  R                  U5      S:X  a  [
        R                  " SU-  5      e[        US5       nUR                  S	5        S S S 5        UR#                  U5        My     U$ ! , (       d  f       N%= f! [         a    [
        R                  " S
U-  5      e[         a    [
        R                  " SU-  5      e[          a    [
        R                  " SU-  5      ef = f)Nr  r   z"%s" is emptywin32*?)globr  r   r  r  r  )r  r  r  r6  r  rr  rs  platformr  r  osr  getsizer5  r  r  r  r:  )	path_exprr  pathsr  r  r  s         rj  input_imagesr    sl   C))""'')*v;!,,_y-HII 6 M1 <<7"y(8C9<L "4	?+EDO77??4(A-"44_t5KLL $%GGAJ & MM$  M &%$ O001F1MNN" R001ID1PQQ$ O001F1MNNOs,   AD'%D7D'
D$	 D'$D''A(Fc                     [          H%  nUR                  U R                  5       :X  d  M#  Us  $    [        R                  " SU -  5      e)Nzunknown rotation value: %s)rV   r!  r  rr  rs  r  ms     rj  parse_rotationargr    s<    66V\\^#H  
$
$%AF%J
KKri  c                     [          H%  nUR                  U R                  5       :X  d  M#  Us  $    [        R                  " SU -  5      e)Nzunknown fit mode: %s)rW   r!  r  rr  rs  r  s     rj  parse_fitargr    s<    66V\\^#H  
$
$%;f%D
EEri  c                    [          H%  nUR                  U R                  5       :X  d  M#  Us  $    SR                  [          Vs/ s H  oR                  PM     sn5      n[        R
                  " SU < SU< S35      es  snf )Nr  zUnsupported page mode: r  r  )r[   r!  r  r  rr  rs  r  r  r  s      rj  parse_panesr    sd    66V\\^#H  ii2A23G

$
$<BGL  3   A>c                 @   [          H%  nUR                  U R                  5       :X  d  M#  Us  $     [        U 5      $ ! [         a     Of = fSR                  [          Vs/ s H  oR                  PM     Os  snf sn5      n[        R                  " SU < SU< S35      e)Nr  zUnsupported magnification: z-. Must be a floating point number or one of: r  )r]   r!  r  r  r  r  rr  rs  r  s      rj  parse_magnificationr  (  s    66V\\^#H V} ii7A78G

$
$4:G	E s   
< 
A	A	A5c                    [          H%  nUR                  U R                  5       :X  d  M#  Us  $    SR                  [          Vs/ s H  oR                  PM     sn5      n[        R
                  " SU < SU< S35      es  snf )Nr  zUnsupported page layout: r  r  )r\   r!  r  r  rr  rs  )r  r  r  s      rj  parse_layoutr  7  sd    66V\\^#H  ii4A45G

$
$>DgN  5r  c                 D    [         R                  " U S5      $ ! [         a     Of = f [         R                  " U S5      $ ! [         a     Of = f [         R                  " U S5      $ ! [         a     Of = f SSKJn   UR                  U 5      $ !    O= f! [         a     Of = f SS Kn UR                  SSU S/5      n[         R                  " [        U5      5      $ ! UR                   a     Of = f! [         a     Of = f[        R                  " S	U -  5      e)
Nz%Y-%m-%dz%Y-%m-%dT%H:%Mz%Y-%m-%dT%H:%M:%Sr   )parserdatez--datez+%szcannot parse date: %s)r
   strptimer  dateutilr  r  ImportError
subprocesscheck_outputfromtimestampr  CalledProcessErrorrr  rs  )r  r  r  utimes       rj  
valid_dater  A  s>     44   )9::   )<== #	<<''	  
6	6++VXvu,MNE ))#e*55 ,, 		   
$
$%<v%E
FFsq    
&&A 
AAA) )
A65A6:B B B
B&%B&*C9 /C# #C65C69
DDc                  v,  ^^^^^^^^^^^^ SS K mSS KmSm SS Km " U4S jSTR                  5      n  " U4S jSTR
                  5      nTR                  5       mTR	                  TS9n/ mSmSmS m0 S	TR                  5       _S
TR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _STR                  5       _TR                  5       TR                  5       TR                  5       TR                  5       TR                  5       TR                  5       TR                  5       TR                  5       TR                  5       TR                  5       S.
EmTS	   R                  S5        TS   R                  S5        TS
   R                  S5        TS   R                  S5        TS   R                  S5        TS   R                  S5        TS   R                  S5        TS   R                  S5        TS   R                  S5        TS    R                  S5        TS!   R                  S5        TS"   R                  S5        UUUUUUUUUU4
S# jnUU4S$ jmUUU4S% jnTR                  S&5        UR                  TR                  TR                  S'9  TR!                  US(S)9mUUUUUUU4S* jmUU4S+ jnTR                  TR                  TR"                  TR                  S,9  TR%                  S-U5        TR	                  U5      nUR                  TR&                  TR                  TR(                  S.9  TR	                  U5      nUR                  TR*                  S/9  TR-                  US0US19R                  TR"                  TR                  TR*                  S.9  TR-                  US2TR.                  S39R                  TR0                  TR                  TR*                  S.9  U " U5      nUR                  TR&                  TR                  TR(                  S.9  TR3                  UR4                  S4S59n	U	R                  TR&                  TR                  TR*                  S.9  TR7                  U	SS59R9                  SSTR:                  S69  U" U	TS   STR.                  S79R9                  SSTR:                  S69  TR7                  U	S	S59R9                  SSTR:                  S69  U" U	TS	   STR.                  S79R9                  SSTR:                  S69  TR=                  U	S8TS   TR.                  S99R9                  S:SS:TR:                  S;9  TR=                  U	S<TS    TR.                  S99R9                  S=SS:TR:                  S;9  TR=                  U	S>TR.                  S39R9                  S?SS:TR:                  S;9  TR3                  UR4                  S@S59n
U
R                  TR&                  TR                  TR*                  S.9  U" U
TS"   /SSA/[?        [@        RC                  5       5      -   Q7SBTR.                  06R9                  SSS=TR:                  S;9  TR7                  U
SCTR.                  SDSE9R9                  S:STR:                  S69  TRE                  U
SFSGSSHSITR.                  SJSK9R9                  S:STR:                  S69  TR7                  U
SLTR.                  SMSE9R9                  S:S:TR:                  S69  TR7                  U
SNTR.                  SOSE9R9                  S=STR:                  S69  TRE                  U
SFSGSSHSITR.                  SPSK9R9                  S=STR:                  S69  TR7                  U
SLTR.                  SQSE9R9                  S=S:TR:                  S69  TR3                  UR4                  SRS59nUR                  TR&                  TR                  TR*                  S.9  U" UTS!   /SSA/[?        [@        RC                  5       5      -   Q7SBTR.                  06R9                  SSS=TR:                  S;9  TR7                  USCTR.                  SDSE9R9                  S:STR:                  S69  TRE                  USFSGSSHSITR.                  SJSK9R9                  S:STR:                  S69  TR7                  USLTR.                  SMSE9R9                  S:S:TR:                  S69  TR7                  USNTR.                  SOSE9R9                  S=STR:                  S69  TRE                  USFSGSSHSITR.                  SPSK9R9                  S=STR:                  S69  TR7                  USLTR.                  SQSE9R9                  S=S:TR:                  S69  TR3                  UR4                  SSS59nUR                  TR&                  TR                  TR*                  S.9  TR7                  USTTR.                  S39R9                  SSTR:                  S69  TRE                  UTR.                  S79R9                  SSTR:                  S69  TR7                  USTR.                  S39R9                  SSTR:                  S69  U" UTS   /[F         Vs/ s H  oRH                  PM     snQ7SBTR.                  06R9                  SSTR:                  S69  TR=                  USUTR.                  TS
   SV9R9                  S:SS:TR:                  S;9  TR7                  USWTR.                  S39R9                  S=STR:                  S69  TRE                  UTR.                  S79R9                  S=STR:                  S69  TR7                  USXTR.                  S39R9                  S?STR:                  S69  TRE                  UTR.                  S79R9                  S?STR:                  S69  TR7                  USYTR.                  S39R9                  SISTR:                  S69  TRE                  UTR.                  S79R9                  SISTR:                  S69  TR7                  USZTR.                  S39R9                  S[STR:                  S69  TRE                  UTR.                  S79R9                  S[STR:                  S69  TR3                  UR4                  S\S59nUR                  TR&                  TR                  TR*                  S.9  TR7                  USTR.                  S39R9                  SSTR:                  S69  TRK                  UTS   TR.                  S]9R9                  SSTR:                  S69  TR7                  USTR.                  S39R9                  SSTR:                  S69  TRK                  UTS   TR.                  S]9R9                  SSTR:                  S69  TR7                  USTR.                  S39R9                  S:STR:                  S69  TRK                  UTS   TR.                  S]9R9                  S:STR:                  S69  TR7                  USTR.                  S39R9                  S=STR:                  S69  TRK                  UTS   TR.                  S]9R9                  S=STR:                  S69  TR7                  US^TR.                  S39R9                  S?STR:                  S69  TRK                  UTS   TR.                  S]9R9                  S?STR:                  S69  TR7                  US_TR.                  S39R9                  SISTR:                  S69  TRK                  UTS   TR.                  S]9R9                  SISTR:                  S69  TR7                  USTR.                  S39R9                  S[STR:                  S69  TRK                  UTR.                  S79R9                  S[STR:                  S69  TR7                  USTR.                  S39R9                  S`STR:                  S69  TRK                  UTR.                  S79R9                  S`STR:                  S69  TR3                  UR4                  SaS59nUR                  TR&                  TR                  TR*                  S.9  TR7                  USbTR.                  S39R9                  SSTR:                  S69  U" UTS   /S/[L         Vs/ s H  oRH                  PM     sn-   Q7SBTR.                  06R9                  SSTR:                  S69  TR7                  UScTR.                  S39R9                  SSTR:                  S69  TRE                  USSSdS[TS   TR.                  SeSf9R9                  SSTR:                  S69  TR7                  USgTR.                  S39R9                  S:STR:                  S69  U" UTS   /SSA/[N         Vs/ s H  oRH                  PM     sn-   Q7SBTR.                  06R9                  S:STR:                  S69  TR7                  UShTR.                  S39R9                  S=STR:                  S69  U" UTS   /S/[P         Vs/ s H  oRH                  PM     sn-   Q7SBTR.                  06R9                  S=STR:                  S69  TR=                  USiTS   TR.                  S99R9                  S?SS:TR:                  S;9  TR=                  USjTSk   TR.                  S99R9                  SISS:TR:                  S;9  TR=                  USlTSm   TR.                  S99R9                  S[SS:TR:                  S;9  TR3                  UR4                  SnS59nUR                  TR&                  TR                  TR*                  S.9  TR7                  USoTR.                  S39R9                  SSTR:                  S69  TR                  5       nUR                  SL5        U" UUSL/TR.                  S79R9                  SSTR:                  S69  TR7                  USpTR.                  S39R9                  SSTR:                  S69  TR                  5       nUR                  Sq5        U" UUSq/TR.                  S79R9                  SSTR:                  S69  TR	                  U5      nUR                  TR*                  S/9  TR-                  USrUS19R                  TR"                  TR                  TR*                  S.9  TR-                  USsTRR                  S19R                  TR0                  TR                  TR*                  S.9  URU                  5         g ! [         a    Sm GNf = fs  snf s  snf s  snf s  snf )tNr   TFc                   &   > \ rS rSrSrU 4S jrSrg)"gui.<locals>.VerticalScrolledFrameiu  zA pure Tkinter vertically scrollable frame.

* Use the 'interior' attribute to place widgets inside the scrollable frame
* Construct and pack/place/grid normally
* This frame only allows vertical scrolling
c                   >^^^	 T
R                   R                  " X/UQ70 UD6  T
R                  U T
R                  S9nUR	                  T
R
                  T
R                  T
R                  S9  T
R                  U SSUR                  SS9mTR	                  T
R                  T
R                  T
R                  S9  UR                  TR                  S9  TR                  S5        TR!                  S5        T
R                  T5      =U l        mTR%                  SSTT
R&                  S9m	UU4S	 jnTR)                  S
U5        UUU	4S jnTR)                  S
U5        g )N)orientr%  sideexpandr   ro   )borderwidthhighlightthicknessyscrollcommandr  )r  r%  r  )command)windowanchorc                 j   > TR                  5       TR                  5       4nTR                  SU-  S9  g )Nz	0 0 %s %s)scrollregion)winfo_reqwidthwinfo_reqheightconfig)eventro  canvasinteriors     rj  _configure_interiorHgui.<locals>.VerticalScrolledFrame.__init__.<locals>._configure_interior  s2     //183K3K3MN;+=>ri  <Configure>c                    > TR                  5       TR                  5       :w  a  TR                  TTR                  5       S9  g g )N)r  )r  winfo_widthitemconfigure)r  r  r  interior_ids    rj  _configure_canvasFgui.<locals>.VerticalScrolledFrame.__init__.<locals>._configure_canvas  s?    **,0B0B0DD((F<N<N<P(Q Eri  )Framer  	ScrollbarVERTICALpackYRIGHTFALSECanvassetLEFTBOTHTRUEr  yviewxview_movetoyview_movetor  create_windowNWbind)r~  parentr
  r  
vscrollbarr  r  r  r  r  tkinters          @@@rj  r  +gui.<locals>.VerticalScrolledFrame.__init__}  s7   MM""4=$="= !**48H8H*IJOOw}}OU^^#$)~~ $ F KKW\\W\\KRfll3 "" (/}}V'<<DMH ..q!HWZZ.XK?
 MM-)<=R
 KK'89ri  )r  N)rd  re  rf  rg  __doc__r  rh  r  s   rj  VerticalScrolledFramer  u  s    	(	 (	ri  r  c                   J   > \ rS rSrSrU 4S jrU 4S jrU 4S jrU 4S jrSr	g)	gui.<locals>.OptionMenui  z?OptionMenu which allows the user to select a value from a menu.c                   > SUSTR                   SSS.nSU;   a  US   US'   US	 SU;   a  US   US'   US	 TR                  R                  XSU5        SU l        UR	                  S	5      U l        X l        S	U;   a  US		 U(       a.  TR                  S
[        UR                  5       5      S   -   5      eU R                  U/[        U5      -   5        g)zConstruct an optionmenu widget with the parent MASTER, with
the resource textvariable set to VARIABLE, the initially selected
value VALUE, the other menu values VALUES and an additional
keyword argument command.r   r   r  )r  textvariableindicatoronreliefr  r  stater!  
menubuttontk_optionMenur  zunknown option -r   N)RAISEDWidgetr  
widgetNamerX  callbackvariableTclErrorr  keys
set_values)r~  masterr  r  valuesrR  r  r  s          rj  r   gui.<locals>.OptionMenu.__init__  s      ! ( !..&'B & $Wo77O#F^6
6NNN##D,C-DO"JJy1DM$MF"9%&&'9D<OPQ<R'RSSOOUGd6l23ri  c                 ^   > US:X  a  U R                   $ TR                  R                  X5      $ )Nmenu)_OptionMenu__menur  r  )r~  r!  r  s     rj  r  #gui.<locals>.OptionMenu.__getitem__  s)    v~{{">>--d99ri  c           	         > TR                  U SSS9=o l        UR                  U l        U H7  nUR	                  UTR                  U R                  X0R                  5      S9  M9     X S'   g )Nr  r   )r!  tearoff)labelr  )Menur  _wmenunameadd_command_setitr  r
  )r~  r  r  r  r  s       rj  r  "gui.<locals>.OptionMenu.set_values  se    !(d!KKD; GGDM  W^^DMM1mm%T !    Lri  c                 J   > TR                   R                  U 5        SU l        g)z,Destroy this widget and the associated menu.N)
Menubuttondestroyr  )r~  r  s    rj  r!  gui.<locals>.OptionMenu.destroy  s    &&t,DKri  )__menur
  r  r  r	  N)
rd  re  rf  rg  r  r  r  r  r!  rh  r  s   rj  
OptionMenur    s    M	4:	:
	 	 	ri  r$  )r  r  r4  r   r  r  r  r  r  r  r  r  r  rS  rT  rU  rV  rW  )
rX  rY  pagesize_dropdownpagesize_widthpagesize_heightimgsize_dropdownimgsize_widthimgsize_heightr  r  ru  r|  r'  r  r   r  r%  r(  c                  <  >
 TR                   R                  T	SSS/S9mT(       a  [        5        n T
" U 5        U R                  S5        TR	                  U SS9mS S S 5        T H  nUR                  5       R                  R                  T:  a$  UR                  5       R                  R                  mUR                  5       R                  R                  T:  d  My  UR                  5       R                  R                  mM     T" 5         g ! , (       d  f       N= f)Nz
open image)ra  zC*.bmp *.eps *.gif *.ico *.jpeg *.jpg *.jp2 *.pcx *.png *.ppm *.tiffz	all filesr  )r  r  	filetypesr   rd  )r  filetype)	
filedialogaskopenfilenamesr   r  r5  get_displaylistrectr  r  )rC  rP  docdrawfitz	have_fitzinfilesmaxpageheightmaxpagewidthrootsave_pdfr  s     rj  on_open_buttongui.<locals>.on_open_button  s    
 $$55 # 6 
 aq	iiq5i9  '')..44|C#'#7#7#9#>#>#D#DL'')..55E$($8$8$:$?$?$F$FM	 
 	 s   *D
Dc                 
  > S nT
S   R                  5       S:X  a  OT
S   R                  5       S:X  a'  T
S   R                  5       T
S   R                  5       4nORT
S   R                  5       [        R                  5       ;   a
  [        5       e[	        ST
S   R                  5       -  5      eS nT
S   R                  5       S:X  a  OT
S   R                  5       S:X  a'  T
S   R                  5       T
S	   R                  5       4nORT
S   R                  5       [        R                  5       ;   a
  [        5       e[	        S
T
S   R                  5       -  5      eS n[        UUUT
S   R                  5       T
S   R                  5       5      nS nT
S   R                  5       S:X  a  ONT
S   R                  5       [        ;   a  T
S   R                  5       nO[	        ST
S   R                  5       -  5      eS nT
S   R                  5       S:X  a  ONT
S   R                  5       [        ;   a  T
S   R                  5       nO[	        ST
S   R                  5       -  5      eS nT
S   R                  5       S:X  a  ONT
S   R                  5       [        ;   a  T
S   R                  5       nO[	        ST
S   R                  5       -  5      eS nT
S   R                  5       S:w  a  [        U
4S j[         5       5      nS n	T
S   R                  5       S:w  a  [        U
4S j[         5       5      n	[        T0 SU	_ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _ST
S   R                  5       (       a  T
S   R                  5       OS _SU_ST
S   R                  5       _S U_SU_S!T
S!   R                  5       S":  a  T
S!   R                  5       OS _SU_SU_S#T
S#   R                  5       =(       d    S _S$T
S$   R                  5       =(       d    S _S%T
S%   R                  5       =(       d    S _S&U _S'T
S'   R                  5       _S(S _S)S _S*S _S+S _6  g ),Nr%  ru  customr&  r'  zno such pagesize: %sr(  r)  r*  zno such imgsize: %sr   r4  rS  zno such viewer_panes: %srU  z no such viewer_magnification: %srV  zno such viewer_page_layout: %sr  c              3   l   >#    U  H)  oR                   TS    R                  5       :X  d  M%  Uv   M+     g7f)r  Nr!  rX  rX  r  r
  s     rj  rY  (gui.<locals>.save_pdf.<locals>.<genexpr>k  s-      !%a43E3I3I3K)K:   $4	4r  c              3   l   >#    U  H)  oR                   TS    R                  5       :X  d  M%  Uv   M+     g7f)r  NrA  rB  s     rj  rY  rC  p  s)     Q1&&DN<N<N<P2PQQrD  r  r  r  r  r  r  r  r  r  r0  rT  r   rW  rX  rY  rQ  r  r  r  r  r  )rX  
papernamesr  NotImplementedr  rB  r[   r]   r\   nextrY   rU   r  )r  pagesizearg
imgsizearg	borderargr0  viewer_panesargviewer_magnificationargviewer_page_layoutargcolorspacearg	engineargr
  r7  s             rj  r;  gui.<locals>.save_pdf0  s   #$((*f4%&**,8/0446=N8O8S8S8UUK%&**,
0A0A0CC ""2T:M5N5R5R5TTUU
"#'')V3$%))+x7o.224d;K6L6P6P6RRJ$%))+z/@/@/BB ""1D9K4L4P4P4RRSS	#KOO##%

 ##%/.!%%'83">2668O6n9M9Q9Q9SSTT"&&'++-7()--/=@&*+A&B&F&F&H#2T:P5Q5U5U5WW  !%$%))+v5&'++-;$()=$>$B$B$D!048L3M3Q3Q3SS  !!#v-  !%! M 	>6)QQQI!	
!	
 *.g):):)<)<$w-##%$!	
 ,0>+=+=+?+?4>%%'T	!	

 .2)_-@-@-B-BDO'')!	
 04J/?/C/C/E/ET*%))+4!	
 /3>.B.F.F.H.H^$((*d!	
 .2)_-@-@-B-BDO'')!	
 .2)_-@-@-B-BDO'')!	
 04J/?/C/C/E/ET*%))+4!	
 %!	
 >%%'!	
 "!	
  )!!	
& -.224q8 *+//1)!	
, "9-!	
.  5/!	
0  $$78<<>F$1!	
2 #''=">"B"B"D"L3!	
4  $$78<<>F$5!	
6  7!	
8 ""4599;9!	
: ;!	
< =!	
> ?!	
@ A!	
ri  c                     > TR                   R                  TSSSS/S9n [        U S5       nT" U5        S S S 5        g ! , (       d  f       g = f)Nzsave PDFz.pdf)zpdf documentsz*.pdfr,  )r  r  defaultextensionr-  wb)r/  asksaveasfilenamer5  )filenamerC  r:  r;  r  s     rj  on_save_buttongui.<locals>.on_save_button  sQ    %%77#13EF	 8 
 (D!QQK "!!s	   	>
Aimg2pdf)r%  r  black)bgc                    > TR                  T
R                  5        T(       d3  TR                  TR                  S   S-  TR                  S   S-  SSS9  g T(       d3  TR                  TR                  S   S-  TR                  S   S-  SSS9  g Sn [	        TR                  S   U -
  T	-  TR                  S   U -
  T-  5      nSnTR                  X5      nT
R                  TU   R                  5       R                  US	S
9R                  S5      S9Tl
        TR                  TR                  S   T	U-  -
  S-  TR                  S   TU-  -
  S-  T
R                  TR                  S9  TR                  TR                  S   T	U-  -
  S-  TR                  S   TU-  -
  S-  TR                  S   T	U-  -
  S-  TR                  R                  5       -   TR                  S   TU-  -
  S-  TR                  R                  5       -   SS9  g )Nr   r   r   z7Click on the "Open Image(s)" button in the upper right.white)r  r%  zPPyMuPDF not available. Install the Python fitz module
for preview functionality.r   F)matrixalphappmr|  )r  r  red)outline)deleteALLcreate_textro  minMatrix
PhotoImager1  
get_pixmapr  r  create_imager  create_rectangler  r  )canvas_paddingzoompagenummat_0r  r3  r5  r7  r8  r9  r  s       rj  r4  gui.<locals>.draw  s   gkk"A"A"N	   A"A"/    [[^n,<[[^n,=

 D'))W_ZuEZ2WU^	 * 
 	[[^lT11Q6[[^md22a7::,,	 	 	
 	[[^lT11Q6[[^md22a7[[^lT11Q69K9K9MM[[^md22a7&,,:M:M:OO 	  	
ri  c                 N   > U R                   U R                  4Tl        T" 5         g r{  )r  r  ro  )r  r  r4  s    rj  	on_resizegui.<locals>.on_resize  s    {{ELL1ri  r  r  )r  r  r%  )r%  zOpen Image(s))r  r  Help)r  r  zOutput Options)r  )rowcolumnsticky)r  zSuppress timestamp)r  r  r  r   )ru  rv  
columnspanrw  zonly first framer   zforce large inputr   z
Image sizer?  r  zWidth:size_label_width)r  r  r!  z%.2fg{Gz?r   r   spinbox_width)r  	incrementfrom_tor  r  r!  rk  size_label_width_mmzHeight:size_label_heightspinbox_heightsize_label_height_mmz	Page sizeLayoutr/  zauto orient)r  r  r  zcrop borderzbleed borderztrim borderz
art borderr   zPDF metadata)r  r  zcreation datezmodification dater@  zPDF viewer optionsr  zinitial pagei'  viewer_initial_page_spinbox)r{  r|  r}  r  r  r  r!  r  zpage layoutzfit window to page sizezcenter windowrX  zopen in fullscreenrY  zProgram optionszUnit:z	Language:EnglishzSave PDFExit)+r  tkinter.filedialogr5  r  r  r   Tk	StringVar
BooleanVarIntVar	DoubleVarr  r  r  r  r  r  r  r  TOPr  XButtonDISABLEDr  
LabelFramer  LabelgridWCheckbuttonr  rF  r  SpinboxrW   r!  Entryr[   r]   r\   r!  mainloop) r  r$  appr<  rW  rr  frame_right	top_frameframe1output_optionsimage_size_framepage_size_framelayout_framer  metadata_frameviewer_frameoption_framerv  languagebottom_framer
  r  r3  r4  r5  r6  r7  r8  r9  r:  r;  r  s                        @@@@@@@@@@@@rj  guir  h  sE   I0 0p1W'' 1f ::<D
--t-
$CGLM
C'##%w))+ 	w  " 	""$	
 	'##% 	7$$& 	G%%' 	7$$& 	G%%' 	'$$& 	))+ 	7$$& 	))+ 	w~~/ 	 1 1 3  	g//1!" 	W//1#$ !( 2 2 4$//1$..0!++-",,.#--/ **,!++-'')#..07D: 	NvMbE"KOOF6"V$	##A&	 $$V,	""6*	  '	!!&)	  ( <c
J
 	JJyHH',,w||H4^^CG^,F2
 2
h KKW\\W\\KJ
KKy)--$K'++gllKk*INN		N"NN9?NNKPP\\',,WYY Q  NN961A1ANBGG]]7<<gii H  #;/F
KKW[[GIIKF''>N'ONW[[GIINMM.|M499a		 :  ~tL16AQAQRWWa		 X  MM.xM055!Agii5X~tH~vW=M=MNSSa		 T  !h	  
 dqqd;()	  
 dqqd;08H8H  
dqqd;))&//)Mw{{7<<giiP  8
vj&7&7&9:
: 	
 dqqd;MMxw/?/?FX  
dq799d-OO  	 dq799d-MMt7+;+;BW  
dq799d-MM 	  
 dq799d-OO  	 dq799d-MMt7+;+;BX  
dq799d-(({(KOgkk',,WYYO ! 8
vj&7&7&9:
: 	
 dqqd;MMhg.>.>EW  
dq799d-OO  	 dq799d-MMd'*:*:AV  
dq799d-MM 	  
 dq799d-OO  	 dq799d-MMd'*:*:AW  
dq799d-%%fooH%EL7;;w||'))LMM,XW5E5EMFKKa		 L  OOL(8(8O9>>a		 ?  MM,U'2B2BMCHHa		 I  d5k5<$=WVVW$=ELEUEU
dq799d-m$	  
 dqqd;MM,]':J:JMKPPa		 Q  OOL(8(8O9>>a		 ?  MM,^7;K;KMLQQa		 R  OOL(8(8O9>>a		 ?  MM,]':J:JMKPPa		 Q  OOL(8(8O9>>a		 ?  MM,\9I9IMJOOa		 P  OOL(8(8O9>>a		 ?  ''n'MNW[[GIINMM.wg6F6FMGLLa		 M  MMT']':J:J  
dq799d-MM.xw7G7GMHMMa		 N  MMT(^7;K;K  
dq799d-MM.y8H8HMINNa		 O  MMT)_G<L<L  
dq799d-MM.z9I9IMJOOa		 P  MMT*%5W=M=M  
dq799d-MM.g>N>NMOTTa		 U  MMT.%9AQAQ  
dq799d-MM08H8H  
dq799d-MMT)_G<L<L  
dq799d-MM.y8H8HMINNa		 O  MM.(8(8M9>>a		 ?  MM.z9I9IMJOOa		 P  MM.(8(8M9>>a		 ?  %%foo<P%QL7;;w||'))LMM,WG4D4DMEJJa		 K  ^ (h/hffh/
/ 	
 dq799d-MM,^7;K;KMLQQa		 R  OO/0*  	 dq799d-MM,_G<L<LMMRRa		 S  #$ 8
>1>
> 	
 dq799d-MM,]':J:JMKPPa		 Q  !" (j1jffj1
1 	
 dq799d-&)*	  
 dqqd;,-	  
 dqqd;!)*	  
 dqqd;%%foo<M%NL7;;w||'))LMM,WG4D4DMEJJa		 K  DHHTN|TD61A1ABGGa		 H  MM,[8H8HMINNa		 O    "HLL|X	{':J:JKPPa		 Q  ==-L799%NN<j.NINN\\',,WYY O  NN<fdllNCHH]]7<<gii I  LLNe  	H %>t 0,  ? 2s5   AX AX'
FAX,JAX1LAX6XAX$X#AX$c                     [        U S5       nUR                  S5      nS S S 5        [        W5      S:  a  gUSS  S:H  $ ! , (       d  f       N&= f)Nr  rt   Fr   s   acsp)r5  r6  r  )fnamerC  r}  s      rj  file_is_iccr  $  sH    	eT	avvbz 

4y2~9	 
	s	   ?
Ac                 X    [        U 5      (       d  [        R                  " SU -  5      eU $ )Nz"%s" is not an ICC profile)r  rr  rs  )r  s    rj  validate_iccr  ,  s)    u(()E)MNNLri  c                      S H=  n [         R                  R                  U 5      (       d  M)  [        U 5      (       d  M;  U s  $    g)N)/usr/share/color/icc/sRGB.iccz%/usr/share/color/icc/OpenICC/sRGB.iccz$/usr/share/color/icc/colord/sRGB.iccr  )r  r  r  r  )r{  s    rj  get_default_icc_profiler  2  s>    
 ww~~g&&7## +ri  c            
      B	   Sn [        [        R                  5       5       H  u  pU S[        U   <S SU< S3-  n M     [        R
                  " [        R                  SSU -  S9nUR                  S	S
[        SSS9  UR                  SSSSS9  UR                  SSSS[        -   SS9  UR                  SSSSS9  UR                  SS[        / SS 9  UR                  S!S"S#9nUR                  S$S%S&[        R                  " S'5      [        [        R                  S(5      (       a  [        R                  R                   O[        R                  S)S 9  UR                  S*S+S,["        S-S.9  UR                  S/S0SS1S9  UR                  S2S3[$        S4S.9  UR                  S5SS6S9  UR                  S7SS8S9  UR                  S9SS:[&        R(                  -  S9  [        R*                  S;:X  a  UR                  S<[,        S=S>9  O UR                  S<S?[/        5       S [,        S@SA9  UR                  SBSC[0        -  S#9nUR                  SDSESF[2        SGS.9  UR                  SHSISF[4        SJS.9  UR                  SKSLSM[6        SNS.9  UR                  SOSPSQ[8        [:        R<                  SRS 9  UR                  SSSTSSUS9  UR                  SVSWSXSY[>        [@        RB                  SZS 9  UR                  S[SM[6        S\S.9  UR                  S]SM[6        S^S.9  UR                  S_SM[6        S`S.9  UR                  SaSM[6        SbS.9  UR                  ScSdS#9nUR                  SeSf[D        SgS.9  UR                  ShSi[D        SjS.9  UR                  SkSl[D        SmS.9  UR                  SnSo[D        Sp[        -   Sq[        -   Sr-   S 9  UR                  SsSt[F        SuS.9  UR                  SvSw[F        SxS.9  UR                  SySz[D        S{S.9  UR                  S|S}[D        S~SS9  UR                  SSS#9nUR                  SS[H        SS.9  UR                  SS[J        SS.9  UR                  SS[L        SS.9  UR                  SS[N        SS.9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  U$ )Nr|  z    r   
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.
For images with transparency, the alpha channel will be stored as a separate
soft mask. This is lossless, too.

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:
a  Colorspace:
  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. Note that on Windows cmd.exe the caret symbol is
  the escape character, so you need to put quotes around the option value.
  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

  Use a custom dpi value for the input images:

    $ img2pdf --output out.pdf --imgsize 300dpi 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 Schauer Marin Rodrigues <josch@mister-muffin.de>

Report bugs at https://gitlab.mister-muffin.de/josch/img2pdf/issues
)formatter_classdescriptionepilogra  infiler  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 "-" (or with a filename starting with "-"), pass it to img2pdf by explicitly stating its relative path like "./-". Cannot be used together with --from-file.)metavarr  nargshelpz-vz	--verbose
store_truezOMakes the program operate in verbose mode, printing messages on standard error.)actionr  z-Vz	--versionrD  z	%(prog)s z%Prints version information and exits.)r  rD  r  z--guir  zrun experimental tkinter gui)destr  r  z--from-fileFILEa  Read the list of images from FILE instead of passing them as positional arguments. If this option is used, then the list of positional arguments must be empty. The paths to the input images in FILE are separated by NUL bytes. If FILE is "-" then the paths are expected on standard input. This option is useful if you want to pass more images than the maximum command length of your shell permits. This option can be used with commands like `find -print0`.)r  r  r#  r  zGeneral output argumentsz(Arguments controlling the output format.)r  r  z-oz--outputoutrT  r  z>Makes the program output to a file instead of standard output.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--nodatezSuppresses 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--enginer  a
  Choose PDF engine. Can be either internal, pikepdf or pdfrw. The internal engine does not have additional requirements and writes out a human readable PDF. The pikepdf engine requires the pikepdf Python module and qpdf library, is most featureful, can linearize PDFs ("fast web view") and can compress more parts of it.The pdfrw engine requires the pdfrw Python module but does not support unicode metadata (See https://github.com/pmaupin/pdfrw/issues/39) or palette data (See https://github.com/pmaupin/pdfrw/issues/128).z--first-frame-onlyzBy 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--include-thumbnailsaa  Some multi-frame formats like MPO carry a main image and one or more scaled-down copies of the main image (thumbnails). In such a case, img2pdf will only include the main image and not create additional pages for each of the thumbnails. If this option is set, img2pdf will instead create one page per frame and thus store each thumbnail on its own page.z--pillow-limit-breaka3  img2pdf 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 img2pdfr  z--pdfazOutput a PDF/A-1b compliant document. The argument to this option is the path to the ICC profile that will be embedded into the resulting PDF.)r  r  r  zOutput a PDF/A-1b compliant document. By default, this will embed either /usr/share/color/icc/sRGB.icc, /usr/share/color/icc/OpenICC/sRGB.icc or /usr/share/color/icc/colord/sRGB.icc as the color profile, whichever is found to exist first.)r  constr#  r  r  z(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.

The --pagesize option or the --imgsize option with the --border option will
determine the MediaBox size of the resulting PDF document.
z-Sz
--pagesizeLxLz
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--borderzL[: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--fitFITa  

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.
z-rz
--rotationz--orientationROTa}  
Specifies how input images should be rotated. ROT can be one of auto, none,
ifvalid, 0, 90, 180 and 270. The default value is auto and indicates that input
images are rotated according to their EXIF Orientation tag. The values none and
0 ignore the EXIF Orientation values of the input images. The value ifvalid
acts like auto but ignores invalid EXIF rotation values and only issues a
warning instead of throwing an error. This is useful because many devices like
Android phones, Canon cameras or scanners emit an invalid Orientation tag value
of zero. The values 90, 180 and 270 perform a clockwise rotation of the image.
            z--crop-bordera;  
Specifies the border between the CropBox and the MediaBox. One, or two length
values can be given as an argument, separated by a colon. One value specifies
the border on all four sides. Two values specify the border on the top/bottom
and left/right, respectively. It is not possible to specify asymmetric borders.
z--bleed-bordera<  
Specifies the border between the BleedBox and the MediaBox. One, or two length
values can be given as an argument, separated by a colon. One value specifies
the border on all four sides. Two values specify the border on the top/bottom
and left/right, respectively. It is not possible to specify asymmetric borders.
z--trim-bordera;  
Specifies the border between the TrimBox and the MediaBox. One, or two length
values can be given as an argument, separated by a colon. One value specifies
the border on all four sides. Two values specify the border on the top/bottom
and left/right, respectively. It is not possible to specify asymmetric borders.
z--art-bordera:  
Specifies the border between the ArtBox and the MediaBox. One, or two length
values can be given as an argument, separated by a colon. One value specifies
the border on all four sides. Two values specify the border on the top/bottom
and left/right, respectively. It is not possible to specify asymmetric borders.
zArguments setting metadatazCOptions handling embedded timestamps, title and author information.z--titler  zSets the title metadata valuez--authorr  zSets the author metadata valuez	--creatorr  zSets the creator metadata valuez
--producerr  zimg2pdf z6Sets the producer metadata value (default is: img2pdf )z--creationdater  zSets 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  zSets 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  zSets the subject metadata valuez
--keywordsr  +z>Sets the keywords metadata value (can be given multiple times)zPDF viewer argumentszTPDF files can specify how they are meant to be presented to the user by a PDF viewerz--viewer-panesPANESzInstruct 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-pageNUMzuInstead of showing the first page, instruct the PDF viewer to show the given page instead. Page numbers start with 1.z--viewer-magnificationMAGzInstruct 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-layoutLAYOUTa  Instruct 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), "twopageright" (two pages with odd numbered page on the right) and "twopageleft" (two pages with odd numbered page 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 mode)(r  r  r  rF  rr  ArgumentParserRawDescriptionHelpFormatteradd_argumentr  rM  r  add_argument_groupFileTyper  r  stdoutr  r  r  r   MAX_IMAGE_PIXELSr  r  r  r^  r  r  r  r  rW   r'  r  rV   ru  r  r  r  r  r  r  )rendered_papersizesr   r  r  outargssizeargsmetaargs
viewerargss           rj  get_main_parserr  @  s   z'')**Q-CC + $$ <<qd er#DFL    	   k)4   eL7U   N   ''(> ( G t$%,SZZ%B%B

!!

M       E	   8	   E   5  	 K
 
 
 !  	 ||w 	! 	 	
 	)+' 	 	
 ((8,Z [- ) 0Hd #;   "   	       	  
 	  $ 	  
 	  
 	  
 	  
 ((* ) H
 73R   H35U   YS7X   [( "-.034   	   	   YS7X   M   **$0 + J 	   B	     	  	 K	   P  
  F  
 I  
 Mri  c                 
   [        5       R                  U SS  5      nUR                  (       a"  [        R                  " [        R
                  S9  UR                  (       a  S [        l        UR                  (       a   [        5         [        R                  " S5        [        UR                  UR                  UR                  UR                   UR"                  5      n[%        UR&                  5      S:  aW  [%        UR(                  5      S:  a>  [*        R-                  S[.        R0                  -  5        [        R                  " S5        GO[%        UR&                  5      S:X  a\  [%        UR(                  5      S:X  aC  [3        S[        R4                  S9   [        R6                  R8                  R;                  5       /nO[%        UR&                  5      S:  aC  [%        UR(                  5      S:X  a*  [?        [@        RB                  " UR&                  5      5      nO>[%        UR&                  5      S:X  a%  [%        UR(                  5      S:  a  UR(                  nURD                  b  URD                  S:  a]  [.        RG                  [        R4                  S9  [*        R-                  S[.        R0                  -  5        [        R                  " S5        URD                  [%        W5      :  a]  [.        RG                  [        R4                  S9  [*        R-                  S	[.        R0                  -  5        [        R                  " S5         [I        W0 S
URJ                  _SURL                  _SURN                  _SURP                  _SURR                  _SURT                  _SURV                  _SURX                  _SURZ                  _SUR\                  _SUR^                  _SU_SUR`                  _SURD                  _SURb                  _SURd                  _SURf                  _SURh                  _SURj                  _SURl                  _SURn                  _SURp                  _S URr                  _S!URt                  _S"URv                  _S#URx                  _S$URz                  _S%UR|                  _6  g ! [<         a    [        R                  " S5         GNf = f! [~         a  n[*        R-                  S&[        U5      -   5        [*        R                  [        R
                  5      (       a!  SS KBnUR                  [        R4                  S9  [        R                  " S5         S nAg S nAff = f)'Nr   )levelr   z;%s: error: cannot use --from-file with positional argumentsr   zTReading image from standard input...
Re-run with -h or --help for usage information.)filezD%s: error: argument --viewer-initial-page: must be greater than zerozb%s: error: argument --viewer-initial-page: must be less than or equal to the total number of pagesr  r  r  r  r  r  r  r  r  r  r  r0  rS  rT  rU  rV  rW  rX  rY  rQ  r  r  r  r  r  r  r  r  zerror: )Dr  
parse_argsverboseloggingbasicConfigDEBUGpillow_limit_breakr   r  r  r  exitrB  r5  r>  r/  r   r4  r  ra  r  r  errorr  progr  stderrr  r  r6  KeyboardInterruptr  r   from_iterablerT  print_usager  r  r  r  r  r  r  r  r  r  r  r  rS  rU  rV  rW  rX  rY  outputr  crop_borderbleed_bordertrim_border
art_borderr  r  r  r  r  isEnabledFor	traceback	print_exc)argvr
  r0  ra  r  r  s         rj  mainr    se   ''QR1D||'--0!%xxt||T[[$((D<L<LJ 4;;!DNN 3a 7IFKKW	
 		T[[	Q	3t~~#6!#; 	>	

	ii&&++-.F 
T[[	A	#dnn"5": e))$++67	T[[	Q	3t~~#6#: +##a'CJJ/LL$&,kk2 HHQK##c&k1CJJ/LLBDJKKP HHQK&	
;;	
 **	
 ;;		

 LL	
 ]]	
 **	
 LL	
 LL	
 ]]	
 	
 ;;	
 "	
 **	
 !% 8 8	
  "&!:!:!	
"  $66#	
$ #44%	
& "&!:!:'	
( #44)	
* +	
, "22-	
. ''/	
0 ))1	
2 ''3	
4 oo5	
6 7	
8 ]]9	
:  $66;	
; ! 	HHQK	x  YQ'(w}}--SZZ0s,   )R: E+S! : SS!
U5+B U00U5__main__)r   r  )FNF)NNNNF)xr  rM  r  r  r8  rr  PILr   r   r   r   r   r  r    RGB_AFTER_DIFFERENT_PALETTE_ONLYLOADING_STRATEGYPIL.ExifTagsr	   r
   r   enumr   ry  r   r  r  r  r@  	itertoolsr   r  	getLoggerrd  r  r  r  r  r  r  r^  r  rF  rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   r  r  ra  rm  ro  rq  rs  ru  rw  ry  r  r  r  objectr  r  r  r%  r  r+  r-  rU  rd  r`  r  r  r  rx  compileVERBOSEr  r  r	  r  r  r  r  r  rB  rA  rI  rQ  rf  r  rx  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rb  ri  rj  <module>r     s\  *  
 	   J J
>,-- 	&&GG #
  '        	 				8	$
  l. 	- 	-	
 	- 	- 	- 	- 	/ 	. 	- 	- 	- 	- 	-  
?!" 
>#$ 1
4h$ 	$ 	$	
 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$  
5!" 
5#$ 1
6 
h0	1
<=
y:
;(*>?, HI
P 
23L

 _&67
y.
)FO$
y2
3AH	Y 		 		Y 		) 		y 			 		9 	{# {#~* *,%VP(# (#V+ +
 K	:% :
	 	V Vr( (,	AV 	AD*\ GK|B~<3!l$ **
 JJ
"od OTfR#(""
 EJiX<
 (&xD #' 'T4n,,"2DLF$GNy
x +F	R hh bJ zF eU  J  Ls$   L	  L 	LLL$#L$