
    h'                       S SK Jr  S SKJr  S SKJrJr  SSKJrJ	r	   SSKJ
r
  SrS	S
S
S.rSS jr " S S\	R                  5      rSS jrSS jrSS jr\R&                  " \R(                  \\5        \(       au  \R*                  " \R(                  \5        \R,                  " \R(                  \5        \R.                  " \R(                  S5        \R0                  " \R(                  S5        gg! \ a    Sr Nf = f)    )annotations)BytesIO)IOAny   )Image	ImageFile)_webpTFRGBRGBA)s   VP8 s   VP8Xs   VP8Lc                    U R                  S5      nU SS S:H  nU SS [        ;   nU(       a  U(       a  U(       a  [        (       d   ggg)	Ns   RIFF      s   WEBP   zEimage file could not be identified because WEBP support not installedTF)
startswith_VP8_MODES_BY_IDENTIFIER	SUPPORTED)prefixis_riff_file_formatis_webp_fileis_valid_vp8_modes       E/var/www/html/env/lib/python3.13/site-packages/PIL/WebPImagePlugin.py_acceptr      sR     ++G4!B<7*Lr")AA|0AyW     c                     ^  \ rS rSrSrSrSrSrSS jrSS jr	SS jr
SSS jjrSS	 jrSS
 jrSU 4S jjrSS jrSS jrSrU =r$ )WebPImageFile%   WEBPz
WebP imager   c                   [         R                  " U R                  R                  5       5      U l        U R                  R                  5       u  U l        pp4XR                  S'   US-	  S-  US-	  S-  US-	  S-  US-  4u  pVpxXgX4U R                  S'   X0l        U R                  S:  U l	        US:X  a  S	OUU l
        X@l        U R                  R                  S
5      n	U R                  R                  S5      n
U R                  R                  S5      nU	(       a  XR                  S'   U
(       a  XR                  S'   U(       a  XR                  S'   U R                  SS9  g )Nloop      r   r   
backgroundr   RGBXr   ICCPEXIFzXMP icc_profileexifxmpF)reset)r
   WebPAnimDecoderfpread_decoderget_info_sizeinfon_framesis_animated_moderawmode	get_chunk_reset)self
loop_countbgcolorframe_countmodebg_abg_rbg_gbg_br'   r(   r)   s               r   _openWebPImageFile._open+   s;    --dgglln= >B]]=S=S=U:
J&		&]d"]d"\T!dN	"
D $(t":		,#==1,"fnU$
 mm--f5}}&&v.mm%%f-'2IIm$ $IIf"IIe 	% r   c                `    SU R                   ;  a  g U R                  5       R                  5       $ )Nr(   )r1   getexif_get_merged_dictr8   s    r   _getexifWebPImageFile._getexifM   s&    "||~..00r   c                >    U R                  U5      (       d  g Xl        g N)_seek_check_WebPImageFile__logical_framer8   frames     r   seekWebPImageFile.seekR   s    &&  %r   c                p    U(       a  U R                   R                  5         SU l        SU l        SU l        g )Nr   )r.   r*   _WebPImageFile__physical_frame_WebPImageFile__loaded_WebPImageFile__timestamp)r8   r*   s     r   r7   WebPImageFile._resetY   s,    MM! !r   c                   U R                   R                  5       nU =R                  S-  sl        Uc.  U R                  5         U R	                  S5        Sn[        U5      eUu  p4X@R                  -
  nX@l        XE-  nX4U4$ )Nr   r   z(failed to decode next frame in WebP file)r.   get_nextrS   r7   rO   EOFErrorrU   )r8   retmsgdata	timestampdurations         r   	_get_nextWebPImageFile._get_next`   s    mm$$&" ;KKMIIaL<C3- ///$ 		((r   c                    U R                   U:X  a  g XR                   :  a  U R                  5         U R                   U:  a#  U R                  5         U R                   U:  a  M"  g g rJ   )rS   r7   r_   rM   s     r   _seekWebPImageFile._seeku   sP      E)(((KKM##e+NN ##e+r   c                  > U R                   U R                  :w  a  U R                  U R                  5        U R                  5       u  pnX R                  S'   X0R                  S'   U R                  U l         U R
                  (       a+  U R                  (       a  U R
                  R                  5         [        U5      U l        [        R                  " SSU R                  -   SU R                  5      /U l        [        TU ]=  5       $ )Nr]   r^   raw)r   r   r   )rT   rL   rb   r_   r1   r,   _exclusive_fpcloser   r	   _Tilesizer5   tilesuperload)r8   r\   r]   r^   	__class__s       r   rl   WebPImageFile.load}   s    ==D000JJt++, )-(8%DX%.IIk"$,IIj! 00DM ww4--dmDG"0BAt||TUDIw|~r   c                    g rJ    )r8   poss     r   	load_seekWebPImageFile.load_seek   s    r   c                    U R                   $ rJ   )rL   rF   s    r   tellWebPImageFile.tell   s    ###r   )__loaded__logical_frame__physical_frame__timestampr.   r4   r0   r,   r3   r2   r5   rj   )returnNone)r{   zdict[int, Any] | None)rN   intr{   r|   )T)r*   boolr{   r|   )r{   ztuple[bytes, int, int])r{   zImage.core.PixelAccess | None)rq   r}   r{   r|   )r{   r}   )__name__
__module____qualname____firstlineno__formatformat_descriptionrT   rL   rA   rG   rO   r7   r_   rb   rl   rr   ru   __static_attributes____classcell__)rm   s   @r   r   r   %   sK    F%HO !D1
%)*$$ $r   r   c                n    U R                   S;  a$  U R                  U R                  (       a  SOS5      n U $ )N)r$   r   r   r   r   )r<   converthas_transparency_data)ims    r   _convert_framer      s,    	ww--ZZ"":":FIr   c           
     	   U R                   R                  5       n[        UR                  S/ 5      5      nSnU /U-    H  nU[	        USS5      -  nM     US:X  a  [        XU5        g SnSU;   a  US   nOfSU R                  ;   aV  U R                  S   n[        U[        5      (       a2  U R                  5       nU(       a  XS-  US-   S-   u  pnXUS4nOXwUS4nU R                   R                  S	U R                  R                  S	S5      5      nU R                   R                  S
S5      nU R                   R                  SS5      nU R                   R                  SS 5      nU R                   R                  SS 5      nU R                   R                  SS5      nSnU R                   R                  SS5      nU R                   R                  SS5      nU R                   R                  SS5      nU R                   R                  SS5      nU R                   R                  S5      =(       d    SnU R                   R                  SS5      n[        U[        R                  5      (       a  UR                  5       nU R                   R                  SS5      nU(       a  SnUc  U(       a  SOSnUc  U(       a  SOSn[        U[        [        45      (       a&  [        U5      S:w  d  [        S U 5       5      (       d  SU 3n[!        U5      eUu  nnnnUS -  US!-  -  US"-  -  US-  -  n["        R$                  " U R&                  UUUUUUU5      nSn Sn!U R)                  5       n" U /U-    H  n[	        USS5      n#[+        U#5       Hz  n$UR-                  U$5        [/        U5      n%UR1                  U%R3                  5       [5        U!5      UUUU5        [        U[        [        45      (       a	  U!UU    -  n!OU!U-  n!U S-  n M|     M     U R-                  U"5        UR1                  S [5        U!5      UUUS5        UR7                  UUU5      n&U&c  S#n[!        U5      eUR9                  U&5        g ! U R-                  U"5        f = f)$Nappend_imagesr   r2   r   )r   r   r   r   r#      r"   r^   r    minimize_sizeFkminkmaxallow_mixedlosslessqualityP   alpha_qualityd   methodr'    r(   r)   	            c              3  L   #    U  H  nS Us=:*  =(       a    S:  Os  v   M     g7f)r      Nrp   ).0vs     r   	<genexpr>_save_all.<locals>.<genexpr>   s     4A1<<C<<s   "$z:Background color is not an RGBA tuple clamped to (0-255): r!   r   r   1cannot write file as WebP (encoder returned None))encoderinfocopylistgetgetattr_saver1   
isinstancer}   
getpaletter   ExiftobytestuplelenallOSErrorr
   WebPAnimEncoderri   ru   rangerO   r   addgetimroundassemblewrite)'r   r,   filenamer   r   totalimsr#   palettergbr^   r    r   r   r   r   verboser   r   r   r   r'   r(   r)   r[   r>   r?   r@   r=   enc	frame_idxr]   cur_idxnfridxrN   r\   s'                                          r   	_save_allr      s3   ..%%'K"=>M Etm#j!,, $zbh(4J{" .
		 WW\*
j#&& mmoG!q.JNa3GHaAs^
(j#F
~~!!*bggkk*a.HIH>>fa(DNN&&>M>>fd+D>>fd+D..$$]E:KG~~!!*e4Hnn  B/GNN&&<M^^!,F..$$]39rK>>fb)D$

##||~
..

UB
'C |q!|r1 zD%=11z?a4444J:,Wcl (D$d"*,	:daiHJ 


	C IIggiG4-'C#z1-CSz&s+ KKM)$! hu66)!44I)IQ	) "	 (6 	 GGD%	"Hg}aH <<T3/D|AclHHTN 	s   +B#Q3 3Rc                L   U R                   R                  SS5      nU R                   R                  SS5      nU R                   R                  SS5      nU R                   R                  S5      =(       d    SnU R                   R                  S	S
5      n[        U[        R                  5      (       a  UR                  5       nUR                  S5      (       a  USS  nU R                   R                  SS5      nU R                   R                  SS5      n	U R                   R                  S5      (       a  SOSn
[        U 5      n [        R                  " U R                  5       U[        U5      [        U5      UU	U
UU5	      nUc  Sn[        U5      eUR                  U5        g )Nr   Fr   r   r   r   r'   r   r(   r   s   Exif     r)   r   r   exactr   r   r   )r   r   r   r   r   r   r   r   r
   
WebPEncoder   floatr   r   )r   r,   r   r   r   r   r'   r(   r)   r   r   r\   r[   s                r   r   r     sU   ~~!!*e4Hnn  B/GNN&&<M..$$]39rK>>fc*D$

##||~''ABx
..

UB
'C^^!,F##G,,A!E		B

gm
D |AclHHTNr   z.webpz
image/webpN)r   bytesr{   z
bool | str)r   Image.Imager{   r   )r   r   r,   z	IO[bytes]r   zstr | bytesr{   r|   )
__future__r   ior   typingr   r   r   r   r	   r
   r   ImportErrorr   r   r   r   r   r   register_openr   register_saveregister_save_allregister_extensionregister_mimerp   r   r   <module>r      s    "   I  n$I'' n$byxD   M((- A	,,e4	M00)<	]117;	,,l;	 a	  Is   C0 0C;:C;