
    (ph-                    *   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S
.rSSSS.rSS jr " S S\	R                  5      rSS jrSS jr\R(                  " \R*                  \\5        \(       a  \R,                  " \R*                  \5        \
R.                  (       a  \R0                  " \R*                  \5        \R2                  " \R*                  S5        \R4                  " \R*                  S5        gg! \ a    Sr Nf = f)    )annotations)BytesIO)IOAny   )Image	ImageFile)_webpTF)RGBXRGBARGB)r   r   r   r   )s   VP8 s   VP8Xs   VP8Lc                    U S S S:H  nU SS S:H  nU SS [         ;   nU(       a  U(       a  U(       a  [        (       d   ggg	)
N   s   RIFF      s   WEBP   zEimage file could not be identified because WEBP support not installedTF)_VP8_MODES_BY_IDENTIFIER	SUPPORTED)prefixis_riff_file_formatis_webp_fileis_valid_vp8_modes       F/var/www/html/venv/lib/python3.13/site-packages/PIL/WebPImagePlugin.py_acceptr      sR     !*/!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	 rSS
 jrU 4S jrSS jrSU 4S jjrSrU =r$ )WebPImageFile)   WEBPz
WebP imager   c                Z   [         R                  (       d  [         R                  " U R                  R	                  5       5      u  po0l        pEU(       a  X@R                  S'   U(       a  XPR                  S'   X#4U l        [        U5      U l        SSU R                  -   SU R                  4/U l        SU l        SU l        g [         R                  " U R                  R	                  5       5      U l        U R                  R!                  5       u  p#pgpX#4U l        X`R                  S'   US	-	  S
-  US-	  S
-  US-	  S
-  US
-  4u  ppXX4U R                  S'   Xl        U R                  S:  U l        U	S:X  a  SOU	U l        Xl        / U l        U R                  R%                  S5      nU R                  R%                  S5      nU R                  R%                  S5      nU(       a  X@R                  S'   U(       a  XPR                  S'   U(       a  XR                  S'   U R'                  SS9  g )Nicc_profileexifrawr   r   r   r   Floop      r   r   
backgroundr   r   ICCPEXIFzXMP xmp)reset)r
   HAVE_WEBPANIM
WebPDecodefpread_modeinfo_sizer   sizemodetilen_framesis_animatedWebPAnimDecoder_decoderget_inforawmode	get_chunk_reset)selfdatawidthheightr!   r"   
loop_countbgcolorframe_countr5   bg_abg_rbg_gbg_br+   s                  r   _openWebPImageFile._open/   s   ""AFAQAQB>D[ +6		-($(		&!DJdmDG$))!3Q		BCDIDM$D --dgglln= AE@V@V@X=zK]
&		&]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"   )r2   getexif_get_merged_dict)r?   s    r   _getexifWebPImageFile._getexifc   s&    "||~..00r   c                >    U R                  U5      (       d  g Xl        g N)_seek_check_WebPImageFile__logical_framer?   frames     r   seekWebPImageFile.seekh   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)r?   r,   s     r   r>   WebPImageFile._reseto   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_nextr[   r>   rW   EOFErrorr]   )r?   retmsgr@   	timestampdurations         r   	_get_nextWebPImageFile._get_nextv   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 rR   )r[   r>   rf   rU   s     r   _seekWebPImageFile._seek   sP      E)(((KKM##e+NN ##e+r   c                  > [         R                  (       a  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        SSU R                  -   SU R                  4/U l        [        TU ]=  5       $ )Nrd   re   r#   r$   r   )r
   r-   r\   rT   ri   rf   r2   r/   _exclusive_fpcloser   r4   r<   r6   superload)r?   r@   rd   re   	__class__s       r   ro   WebPImageFile.load   s    }} 4 44

4//0 -1NN,<))2		+&(0		*% $ 4 4 77t11GGMMO!$-#Vdii%7DLLIJ	w|~r   c                    g rR    )r?   poss     r   	load_seekWebPImageFile.load_seek   s    r   c                b   > [         R                  (       d  [        TU ]  5       $ U R                  $ rR   )r
   r-   rn   tellrT   )r?   rp   s    r   rx   WebPImageFile.tell   s$    ""7<>!###r   )__loaded__logical_frame__physical_frame__timestampr:   r1   r3   r/   r8   r7   r<   r6   )returnNone)r~   zdict[str, Any] | None)rV   intr~   r   )T)r,   boolr~   r   )rt   r   r~   r   )r~   r   )__name__
__module____qualname____firstlineno__formatformat_descriptionr\   rT   rJ   rO   rW   r>   rf   ri   ro   ru   rx   __static_attributes____classcell__)rp   s   @r   r   r   )   sK    F%HO2!h1
%)*&$ $r   r   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&                  S   U R&                  S   UUUUUUU5	      nSn Sn!U R)                  5       n" U /U-    GHe  n[	        USS5      n#[+        U#5       GHD  n$UR-                  U$5        UR/                  5         Un%UR0                  n&UR0                  [2        ;  a{  S#UR0                  ;   =(       dI    S$UR0                  ;   =(       d3    UR0                  S%:H  =(       a    S#UR4                  R7                  5       ;   n'U'(       a  S&OS'n&UR9                  U&5      n%U&S':X  a  S(n&UR;                  U%R                  S)U&5      [=        U!5      U%R&                  S   U%R&                  S   U&UUUU5	        [        U[        [        45      (       a	  U!UU    -  n!OU!U-  n!U S-  n GMG     GMh     U R-                  U"5        UR;                  S [=        U!5      SSSUUUS5	        UR?                  UUU5      n(U(c  S*n[!        U5      eURA                  U(5        g ! U R-                  U"5        f = f)+Nappend_imagesr   r7   r   )r   r   r   r   r(      r'   re   r%   minimize_sizeFkminkmaxallow_mixedlosslessqualityP   alpha_qualityd   methodr!    r"   r+   	         r   c              3  L   #    U  H  nS Us=:*  =(       a    S:  Os  v   M     g7f)r      Nrs   ).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   AaPr   r   r   r#   1cannot write file as WebP (encoder returned None))!encoderinfocopylistgetgetattr_saver2   
isinstancer   
getpaletter   ExiftobytestuplelenallOSErrorr
   WebPAnimEncoderr4   rx   rangerW   ro   r5   _VALID_WEBP_MODESimgetpalettemodeconvertaddroundassemblewrite))r   r/   filenamer   r   totalimsr(   palettergbre   r%   r   r   r   r   verboser   r   r   r   r!   r"   r+   rc   rG   rH   rI   rF   enc	frame_idxrd   cur_idxnfridxrV   r<   alphar@   s)                                            r   	_save_allr      s   ..%%'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
 ((88#44sxx P#((?PHHONsvv7L7L7N0N 
 ).f5GKK0Ee#$G MM%1)$JJqMJJqM!
 hu66)!44I)IQ	M "	 (Z 	 GGD%	"Aq"hPQR <<T3/D|AclHHTN 	s   <E0U U'c                   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 R                  [        ;  a$  U R                  U R                  (       a  SOS5      n [        R                  " U R                  5       U R                  S   U R                  S   U[        U5      [        U5      U R                  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   
startswithr5   _VALID_WEBP_LEGACY_MODESr   has_transparency_datar
   
WebPEncoder4   floatr   r   )r   r/   r   r   r   r   r!   r"   r+   r   r   r@   rc   s                r   r   r   ?  s   ~~!!*e4Hnn  B/GNN&&<M..$$]39rK>>fc*D$

##||~''ABx
..

UB
'C^^!,F##G,,A!E	ww..ZZ"":":F






gm
D |AclHHTNr   z.webpz
image/webpN)r   bytesr~   z
bool | str)r   zImage.Imager/   z	IO[bytes]r   zstr | bytesr~   r   )
__future__r   ior   typingr   r   r   r   r	   r
   r   ImportErrorr   r   r   r   r   r   r   register_openr   register_saver-   register_save_allregister_extensionregister_mimers   r   r   <module>r      s   "   I
 "4= #'6   D$I'' D$NL^#L   M((- A	,,e4 4 4i@	]117;	,,l; u
  Is   D DD