
    \iu0                    x   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J	r	J
r
JrJr  \R                  " S5      r\(       a  SSKJr  SrS	rS!S
 jr        S"S jr        S"S jr        S"S jr        S"S jr " S S5      r " S S\
R                  5      rS#S jrS$S jr\	R6                  " \R8                  \\5        \	R:                  " \R8                  S5        \	R<                  " \R8                  \5        \	R>                  " \R8                  S5        \ S:X  a  \!" \RD                  5      S:  a  \#" S5        \RH                  " 5         \%" \RD                  S   S5       r&\" \&5      r'\'RP                  S    H+  r)\)=u  r*r+r,\'l)        \'R[                  S\* S\+ S\, S35        M-     \	RJ                  " \RD                  S   5       r.\.R[                  S5        SSS5        \R^                  S :X  a  \R`                  " S5        SSS5        gg! , (       d  f       N:= f! , (       d  f       g= f)%    )annotationsN)IO   )Image	ImageFilePngImagePluginfeaturesjpg_2000)Jpeg2KImagePlugins   icns   c                V    [         R                  " SU R                  [        5      5      $ )Nz>4sI)structunpackread
HEADERSIZE)fobjs    V/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/PIL/IcnsImagePlugin.py
nextheaderr   %   s    ==:!677    c                    Uu  p4U R                  U5        U R                  S5      nUS:w  a  Sn[        U5      e[        XS-   US-
  4U5      $ )N   s       z'Unknown signature, expecting 0x00000000)seekr   SyntaxErrorread_32)r   start_lengthsizestartlengthsigmsgs          r   read_32tr!   )   sW     #OUIIe
))A,C
!!7#4!)VaZ0$77r   c           
     h   Uu  p4U R                  U5        US   US   -  US   US   -  4nUS   US   -  nXFS-  :X  a0  U R                  U5      n[        R                  " SXWSSSS5      nSU0$ [        R                  " SUS5      n[        S5       GH  n	/ n
UnUS:  a  U R                  S5      nU(       d  OUS   nUS-  (       a:  US	-
  nU R                  S5      n[        U5       H  nU
R                  U5        M     O%US-   nU
R                  U R                  U5      5        X-  nUS::  a  OUS:  a  M  US:w  a  S
[        U5       S3n[        U5      e[        R                  " SUSR                  U
5      SSSS5      nUR                  R                  UR                  U	5        GM     SU0$ )zb
Read a 32bit RGB icon resource.  Seems to be either uncompressed or
an RLE packbits-like scheme.
r      r      RGBrawN   }   zError reading channel [z left]Lr   )r   r   r   
frombuffernewrangeappendreprr   joinimputband)r   r   r   r   r   
pixel_sizesizesqindatar0   band_ixdata	bytesleftbytebyte_int	blocksizeir    bands                     r   r   r   6   s    #OUIIeq'DG#T!WtAw%67J]Z]*F!6"eZq!L8 2;3 YYuj$/QxGDIa-yy|7d? (3I99Q<D"9-D) . !)1IKK		) 45&	> a-  A~/Y/@G!#&&##CSXXd^UCQRTUVDEEMM$''7+/  0 2;r   c           	         US   nU R                  U5        US   US   -  US   US   -  4nUS   US   -  n[        R                  " SX@R                  U5      SSSS5      nSU0$ )Nr   r#   r   r)   r&   A)r   r   r*   r   )r   r   r   r   r2   r3   r<   s          r   read_mkr?   c   s|     OEIIeq'DG#T!WtAw%67J]Z]*FCYYv->sAqQD;r   c                   Uu  p4U R                  U5        U R                  S5      nUR                  S5      (       aK  U R                  U5        [        R                  " U 5      n[
        R                  " UR                  5        SU0$ UR                  S5      (       d  US:X  a  [        (       d  Sn[        U5      eU R                  U5        U R                  U5      n[        R                  " U5      n	[        R                  " U	5      n[
        R                  " UR                  5        UR                  S:w  a  UR                  S5      nSU0$ Sn[        U5      e)N   s   PNG

RGBA)s   OQs   

s      jP  

zQUnsupported icon subimage format (rebuild PIL with JPEG 2000 support to fix this)z Unsupported icon subimage format)r   r   
startswithr   PngImageFiler   _decompression_bomb_checkr   enable_jpeg2k
ValueErrorioBytesIOr   Jpeg2KImageFilemodeconvert)
r   r   r   r   r   r   r0   r    
jp2kstreamfs
             r   read_png_or_jpeg2000rO   o   s    #OUIIe
))B-C ~~011		%((.''0|ABB99}6  S/!		%YYv&
JJz"..q1''077fF#B|0or   c                      \ rS rSrS\4/S\4/S\4/S\4/S\4/S\4S\4S	\4/S
\4/S\4/S\4S\4/S\4S\4S\4/S\4/S\4S\4S\4/S.rSS jr	SS jr
SS jrS S jr S!   S"S jjrSrg)#IcnsFile      ic10   ic09   ic14   ic08   ic13   ic07s   it32s   t8mks   icp6   ic12s   ih32s   h8mks   icp5s   il32s   l8mk   ic11s   icp4s   is32s   s8mk))   r[   r#   )r[   r[   r   )   r\   r#   )r\   r\   r   )r'   r'   r#   )r'   r'   r   )@   r]   r   )    r^   r#   )0   r_   r   )r^   r^   r   )   r`   r#   )r`   r`   r   c                d   0 U l         Xl        [        U5      u  p#[        U5      (       d  Sn[	        U5      e[
        nXS:  an  [        U5      u  p&US::  a  Sn[	        U5      eU[
        -  nU[
        -  nXV4U R                   U'   UR                  U[        R                  5        XV-  nXS:  a  Mm  gg)z0
fobj is a file-like object as an icns resource
znot an icns filer   zinvalid block headerN)	dctr   r   _acceptr   r   r   rH   SEEK_CUR)selfr   r   filesizer    r;   r:   s          r   __init__IcnsFile.__init__   s    
 	"4(s||$Cc""l'-NCA~,!#&&OA#INDHHSMIIi-NA lr   c                    / nU R                   R                  5        H3  u  p#U H(  u  pEX@R                  ;   d  M  UR                  U5          M1     M5     U$ N)SIZESitemsrb   r-   )re   sizesr   fmtsfmtreaders         r   	itersizesIcnsFile.itersizes   sK    ****,JD#((?LL&  $ -
 r   c                `    U R                  5       nU(       d  Sn[        U5      e[        U5      $ )NzNo 32bit icon resources found)rq   r   max)re   rm   r    s      r   bestsizeIcnsFile.bestsize   s+     1Cc""5zr   c                    0 nU R                   U    HG  u  p4U R                  R                  U5      nUc  M%  UR                  U" U R                  XQ5      5        MI     U$ )z
Get an icon resource as {channel: array}.  Note that
the arrays are bottom-up like windows bitmaps and will likely
need to be flipped or transposed in some way.
)rk   rb   getupdater   )re   r   rb   coderp   descs         r   dataforsizeIcnsFile.dataforsize   sT      JJt,LD88<<%D

6$))T89 - 
r   Nc                *   Uc  U R                  5       nO[        U5      S:X  a  US   US   S4nU R                  U5      nUR                  S5      nU(       a  U$ US   R	                  5       n UR                  US   5        U$ ! [         a     U$ f = f)Nr#   r   r   rB   r%   r>   )ru   lenr|   rx   copyputalphaKeyError)re   r   channelsr0   s       r   getimageIcnsFile.getimage   s     <==?DY!^GT!Wa(D##D)\\&!Ie_!!#	KK& 	  			s   .B 
BB)rb   r   )r   	IO[bytes]returnNone)r   zlist[tuple[int, int, int]])r   tuple[int, int, int])r   r   r   dict[str, Image.Image]rj   )r   z-tuple[int, int] | tuple[int, int, int] | Noner   Image.Image)__name__
__module____qualname____firstlineno__rO   r!   r?   r   rk   rg   rq   ru   r|   r   __static_attributes__ r   r   rQ   rQ      s    "678 "678 "678 "678 "678*+hg

  456 456(7G*<=*+gg

  456*+gg
)E6. EIA	 r   rQ   c                  t    \ rS rSrSrSrSrSS jr\SS j5       r	\	R                  SS j5       r	SSS	 jjrS
rg)IcnsImageFile   a  
PIL image support for Mac OS .icns files.
Chooses the best resolution, but will possibly load
a different size image if you mutate the size attribute
before calling 'load'.

The info dictionary has a key 'sizes' that is a list
of sizes that the icns file has.
ICNSzMac OS icns resourcec                X   [        U R                  5      U l        SU l        U R                  R	                  5       U R
                  S'   U R                  R                  5       U l        U R                  S   U R                  S   -  U R                  S   U R                  S   -  4U l        g )NrB   rm   r   r#   r   )	rQ   fpicns_moderq   inforu   	best_sizer   re   s    r   _openIcnsImageFile._open  s    TWW%	
!YY002		'++-NN1q 11NN1q 11
	r   c                    U R                   $ rj   )_sizer   s    r   r   IcnsImageFile.size  s    zzr   c                    U R                   S    H;  nUS   US   -  US   US   -  4nUS   US   -  nUS   US   -  U:X  d  M5  Xl          g    Sn[        U5      e)Nrm   r   r#   r   z2This is not one of the allowed sizes of this image)r   r   rG   )re   valuer   simple_sizescaler    s         r   r   r     s|     IIg&Dq'DG+T!WtAw->>KNeAh.E1~a(E1"
 ' Cor   Nc                   Ub'  U R                   S S u  p#X!-  X1-  4U l         X#U4U l        [        R                  R                  U 5      nU R                  b&  U R
                  R                   U R                   :X  a  U$ U R                  5         U R                  R                  U R                  5      nUR                  5       nUR
                  U l        UR                  U l
        UR                   U l         U$ )Nr#   )r   r   r   load_imr0   load_preparer   r   rK   r   )re   r   widthheightpxr0   s         r   r   IcnsImageFile.load&  s     IIbqMMEv~5DI"E1DN[[d#88DGGLLDII$=IYY/ WWY%%WW
GG		r   )r   r   r   r   r0   r   )r   r   )r   tuple[int, int])r   r   r   r   rj   )r   z
int | Noner   zImage.core.PixelAccess | None)r   r   r   r   __doc__formatformat_descriptionr   propertyr   setterr   r   r   r   r   r   r      sO     F/
   
[[
 
 r   r   c           	     @   [        US5      (       a  UR                  5         SSSSSSSSS.nU R                  R                  S	/ 5       V s0 s H  o R                  U _M     nn 0 n[        UR                  5       5       HW  nXd;   a  XF   OW R                  Xf45      n[        R                  " 5       nUR                  US
5        UR                  5       XV'   MY     / n	UR                  5        H-  u  pXV   nU	R                  U
[        [        U5      -   U45        M/     UR!                  ["        5        [        nU[        S[        U	5      -  -   -  nU[%        S U	 5       5      -  nUR!                  [&        R(                  " SU5      5        UR!                  S5        UR!                  [&        R(                  " S[        [        U	5      [        -  -   5      5        U	 H@  nUR!                  US   5        UR!                  [&        R(                  " SUS   5      5        MB     U	 HT  nUR!                  US   5        UR!                  [&        R(                  " SUS   5      5        UR!                  US   5        MV     [        US5      (       a  UR                  5         ggs  sn f )zU
Saves the image as a series of PNG files,
that are then combined into a .icns file.
flushr'   r\   r[   i   r^   r]   )rX   rV   rT   rS   rZ   rY   rW   rU   append_imagespngr   c              3  *   #    U  H	  oS    v   M     g7f)r   Nr   ).0entrys     r   	<genexpr>_save.<locals>.<genexpr>f  s     5WEQxWs   z>is   TOC r   r   r#   N)hasattrr   encoderinforx   r   setvaluesresizerH   rI   savegetvaluerl   r-   r   r   writeMAGICsumr   pack)r0   r   filenamerm   provided_imagessize_streamsr   imagetempentriestypestreamfile_lengthr   s                 r   _saver   >  s7   
 r7

 	E /1nn.@.@RT.UV.Uxx|.UOVLELLN# & !D<( 	 zz|

4!]]_ $ Gkkm
#j3v;6?@ $
 HHUOK:CL 000K35W555KHHV[[{+, HHWHHV[[zCL:,EEFG
q
T58,- 
 
q
T58,-
q 
 r7

 M Ws   Jc                ,    U R                  [        5      $ rj   )rC   r   )prefixs    r   rc   rc   z  s    U##r   z.icnsz
image/icns__main__r#   z)Syntax: python3 IcnsImagePlugin.py [file]rbrm   zout--z.pngzout.pngwindows)r   r   r   ztuple[bytes, int])r   r   r   r   r   r   r   r   )r0   r   r   r   r   zstr | bytesr   r   )r   bytesr   bool)1
__future__r   rH   osr   systypingr    r   r   r   r	   check_codecrF   r   r   r   r   r!   r   r?   rO   rQ   r   r   rc   register_openr   register_extensionregister_saveregister_mimer   r   argvprintexitopenr   imfr   r   r   r   r   r   r0   platform	startfiler   r   r   <module>r      sP  & # 	 	  
  8 8$$Z0#
8
8

8#2
8:N
8
8*
*#2*:N**Z	
	#2	:N		"
"#2":N""Jb bR>I'' >B9x$   M((- A   --w 7   M((% 0   M((, 7z
388}q9:
	chhqk4	 BBHHW%D.22 E6538HHtE7!F81UG489 & ZZ$GGI %<<9$LL# 
!	   %$ 
!	 s%   .A&H+H&*H+
H(	$H++
H9