
    h2                       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  SSK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\	R:                  " \R<                  \\5        \	R>                  " \R<                  S5        \	R@                  " \R<                  \5        \	RB                  " \R<                  S5        \"S:X  a  \#" \RH                  5      S:  a  \%" S5        \RL                  " 5         \'" \RH                  S   S5       r(\" \(5      r)\)RT                  S    H+  r+\+=u  r,r-r.\)l+        \)R_                  S\, S\- S\. S35        M-     \	RN                  " \RH                  S   5       r0\0R_                  S 5        SSS5        \Rb                  S!:X  a  \Rd                  " S 5        SSS5        gg! , (       d  f       N:= f! , (       d  f       g= f)&    )annotationsN)IO   )Image	ImageFilePngImagePluginfeatures)	deprecatejpg_2000)Jpeg2KImagePlugins   icns   c                V    [         R                  " SU R                  [        5      5      $ )Nz>4sI)structunpackread
HEADERSIZE)fobjs    E/var/www/html/env/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indatar1   band_ixdata	bytesleftbytebyte_int	blocksizeir!   bands                     r   r   r   7   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   r3   r4   r=   s          r   read_mkr@   d   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    r1   r!   
jp2kstreamfs
             r   read_png_or_jpeg2000rP   p   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   )   ra   r$   )ra   ra   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   rI   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itemsrc   r.   )rf   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)rr   r   max)rf   rn   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.
)rl   rc   getupdater   )rf   r   rc   coderq   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   rC   r&   r?   )rv   lenr}   ry   copyputalphaKeyError)rf   r   channelsr1   s       r   getimageIcnsFile.getimage   s     <==?DY!^GT!Wa(D##D)\\&!Ie_!!#	KK& 	  			s   .B 
BB)rc   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]rk   )r   z-tuple[int, int] | tuple[int, int, int] | Noner   Image.Image)__name__
__module____qualname____firstlineno__rP   r"   r@   r   rl   rh   rr   rv   r}   r   __static_attributes__ r   r   rR   rR      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   rR   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 )NrC   rn   r   r$   r   )	rR   fpicns_moderr   inforv   	best_sizer   rf   s    r   _openIcnsImageFile._open  s    TWW%	
!YY002		'++-NN1q 11NN1q 11
	r   c                    U R                   $ rk   )_sizer   s    r   r   IcnsImageFile.size  s    zzr   c                $   [        U5      S:X  a'  [        SSS5        XR                  S   ;   a  Xl        g ONU 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)
Nr%   z&Setting size to (width, height, scale)rB   zload(scale)rn   r   r$   r   z2This is not one of the allowed sizes of this image)r   r
   r   r   rH   )rf   valuer   simple_sizescaler!   s         r   r   r     s    u:?>MR		'**"
 + 		'*"1gQ/a471BB#A%(2q>E!H,5!&J + Cor   Nc                   Uc  [        U R                  5      S:X  aW  Uc(  [        U R                  5      S:X  a  U R                  S   nUc   e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   r   r   load_imr1   load_preparer   r   rL   r   )rf   r   widthheightpxr1   s         r   r   IcnsImageFile.load-  s    DII! 3}TYY1!4		!$$$ IIbqMMEv~5DI"E1DN[[d#88DGGLLDII$=IYY/ WWY%%WW
GG		r   )r   r   r   r   r1   r   )r   r   )r   &tuple[int, int] | tuple[int, int, int])r   r   r   r   rk   )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^   )rY   rW   rU   rT   r[   rZ   rX   rV   append_imagespngr   c              3  *   #    U  H	  oS    v   M     g7f)r   Nr   ).0entrys     r   	<genexpr>_save.<locals>.<genexpr>p  s     5WEQxWs   z>is   TOC r   r   r$   N)hasattrr   encoderinfory   r   setvaluesresizerI   rJ   savegetvaluerm   r.   r   r   writeMAGICsumr   pack)r1   r   filenamern   provided_imagessize_streamsr   imagetempentriestypestreamfile_lengthr   s                 r   _saver   H  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      $ rk   )rD   r   )prefixs    r   rd   rd     s    U##r   z.icnsz
image/icns__main__r$   z)Syntax: python3 IcnsImagePlugin.py [file]rbrn   zout--z.pngzout.pngwindows)r   r   r   ztuple[bytes, int])r   r   r   ztuple[int, int]r   r   r   r   )r1   r   r   r   r   zstr | bytesr   r   )r   bytesr   bool)3
__future__r   rI   osr   systypingr    r   r   r   r	   
_deprecater
   check_codecrG   r   r   r   r   r"   r   r@   rP   rR   r   r   rd   register_openr   register_extensionregister_saveregister_mimer   r   argvprintexitopenr   imfr   r   r   r   r   r   r1   platform	startfiler   r   r   <module>r      sU  & # 	 	  
  8 8 !$$Z0#
8
8

8#2
8:N
8
8*
*#2*:N**Z	
	#2	:N		"
"#2":N""Jb bR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%   4A&H1H ,*H1 
H.	*H11
H?