
    (ph.                    $   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
 rS rS rS rS 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    F/var/www/html/venv/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!   )   sU    "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	blocksizeir    bands                    r   r   r   4   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|Aw$; $s
I99Q<D"9-D) . !%q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>   _   sz    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S S S:X  aK  U R                  U5        [        R                  " U 5      n[        R
                  " UR                  5        SU0$ US S S:X  d  US S S:X  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   r   s   PNG

RGBAr   s   OQs   

s      jP  

zQUnsupported icon subimage format (rebuild PIL with JPEG 2000 support to fix this)z Unsupported icon subimage format)r   r   r   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_jpeg2000rM   i   s(   "OUIIe
))B-C
2Aw,,		%((.''0|BQ&&r7))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 r	S r
S rS rSS 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))   rY   r#   )rY   rY   r   )   rZ   r#   )rZ   rZ   r   )r'   r'   r#   )r'   r'   r   )@   r[   r   )    r\   r#   )0   r]   r   )r\   r\   r   )   r^   r#   )r^   r^   r   c                R   0 =U l         nXl        [        U5      u  p4[        U5      (       d  Sn[	        U5      e[
        nXd:  ac  [        U5      u  p7US::  a  Sn[	        U5      eU[
        -  nU[
        -  nXg4X#'   UR                  U[        R                  5        Xg-  nXd:  a  Mb  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   rF   SEEK_CUR)selfr   r`   r   filesizer    r:   r9   s           r   __init__IcnsFile.__init__   s    
 3	"4(s||$Cc""l'-NCA~,!#&&OA#I~CH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itemsr`   r-   )rc   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)ro   r   max)rc   rk   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.
)ri   r`   getupdater   )rc   r   r`   codern   descs         r   dataforsizeIcnsFile.dataforsize   sT      JJt,LD88<<%D

6$))T89 - 
r   Nc                B   Uc  U R                  5       n[        U5      S:X  a  US   US   S4nU R                  U5      nUR                  SS 5      nU(       a  U$ UR                  S5      R	                  5       n UR                  US   5        U$ ! [         a     U$ f = f)Nr#   r   r   rA   r%   r=   )rs   lenrz   rv   copyputalphaKeyError)rc   r   channelsr0   s       r   getimageIcnsFile.getimage   s    <==?Dt9>GT!Wa(D##D)\\&$'I\\% %%'	KK& 	  			s   :B 
BB)r`   r   rh   )__name__
__module____qualname____firstlineno__rM   r!   r>   r   ri   re   ro   rs   rz   r   __static_attributes__ r   r   rO   rO      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.r   rO   c                  d    \ rS rSrSrSrSrSS jr\S 5       r	\	R                  S 5       r	S 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 )NrA   rk   r   r#   r   )	rO   fpicns_modero   infors   	best_sizer   rc   s    r   _openIcnsImageFile._open   s    TWW%	
!YY002		'++-NN1q 11NN1q 11
	r   c                    U R                   $ rh   )_sizer   s    r   r   IcnsImageFile.size
  s    zzr   c                   UnX R                   S   ;  a  [        U5      S:X  a  US   US   S4nX R                   S   ;  ap  [        U5      S:X  aa  US   S:X  aX  U R                   S    Vs/ s H  o3S   US   -  US   US   -  4PM     nnX;   a!  U R                   S   UR                  U5         nX R                   S   ;  a  Sn[        U5      eXl        g s  snf )Nrk   r#   r   r   r$   z2This is not one of the allowed sizes of this image)r   r}   indexrE   r   )rc   value	info_sizer   simple_sizesr    s         r   r   r     s    	IIg..3y>Q3F"1y|Q7IYYw//I!#!! DH99WCUCU4a47"DGd1g$56CU   $ IIg.|/A/A%/HI	IIg..FCS/!
s   *Cc                t   [        U R                  5      S:X  aT  U R                  U l        U R                  S   U R                  S   -  U R                  S   U R                  S   -  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   )r}   r   r   r   loadr0   load_preparer   r   rI   r   )rc   pxr0   s      r   r   IcnsImageFile.load"  s    tyy>Q!YYDNq!DNN1$55q!DNN1$55DI
 [[d#77477<<499#<IYY/ WWY%%WW
GG		r   )r   r   r   r   r0   r   N)returnNone)r   r   r   r   __doc__formatformat_descriptionr   propertyr   setterr   r   r   r   r   r   r      sJ     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'   rZ   rY   i   r\   r[   )rV   rT   rR   rQ   rX   rW   rU   rS   append_imagespngr   c              3  *   #    U  H	  oS    v   M     g7f)r   Nr   ).0entrys     r   	<genexpr>_save.<locals>.<genexpr>d  s     5WEQxWs   z>is   TOC r   r   r#   N)hasattrr   encoderinforv   widthsetvaluesresizerF   rG   savegetvaluerj   r-   r   r}   writeMAGICsumr   pack)r0   r   filenamerk   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 S S [         :H  $ )Nr   )r   )prefixs    r   ra   ra   x  s    "1:r   z.icnsz
image/icns__main__r#   z)Syntax: python3 IcnsImagePlugin.py [file]rbrk   zout--z.pngzout.pngwindows)r0   zImage.Imager   z	IO[bytes]r   zstr | bytesr   r   )r   bytesr   bool)1
__future__r   rF   osr   systypingr    r   r   r   r	   check_codecrD   r   r   r   r   r!   r   r>   rM   rO   r   r   ra   register_openr   register_extensionregister_saveregister_mimer   r}   argvprintexitopenr   imfr   r   r   heightscaler   r0   platform	startfiler   r   r   <module>r      s  & # 	 	  
  8 8$$Z0#
88(VD` `NGI'' GT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*G0<*H0
G>	:H
H