
    Bh7                     D    S SK r S SKJr  S/rSS jr\S:X  a  \" 5         gg)    N)png_optimizeoptimizec                 v   SS K nSS KnUR                  SS9nUR                  S5        UR                  S5        UR                  SSSS	S
9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSS
9  UR                  SSSS
9  UR                  SSSS
9  UR                  SSSSS9  UR                  SS [        SS9  UR                  S S!S"S#9  UR                  S$S% S&S'9  UR                  U 5      nUR                  (       a  [        OS( nUR                  b  UR                  =pgOS)u  pgUR                  (       a
  US*-  nUS*-  n[        UR                  S+5       nUR                  5       n	S S S 5        U" S,UR                   35        [        W	UR                  UR                  UR                  UR                   UR"                  UR$                  UUS-9	n
['        U	5      nU" S.U S/US0-   S135        ['        U
5      n[)        X-  S2-  S35      nU" S4U S/US0-   S5U S635        X:  a	  U" S75        O2X:X  a	  U" S85        O$UR*                  (       a	  U" S95        O
U" S:5        U	n
UR,                  (       dd  UR.                  R1                  UR2                  5      (       a:  [5        S;UR2                   S<35      R7                  5       R9                  5       S=:w  a  g[        UR2                  S>5       nUR;                  U
5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       g = f)?Nr   zpython -m zopfli.png)proginfileoutfilez-vz	--verbose
store_truezprint more info)actionhelpz-mcompress_morez<compress more: use more iterations (depending on file size).)r
   destr   z-y	overwritez#do not ask about overwriting files.)r   r
   r   z--lossy_transparentz;remove colors behind alpha channel 0. No visual difference.z--lossy_8bitz6convert 16-bit per channel image to 8-bit per channel.z--always_zopflifyzHalways output the image encoded by Zopfli, even if bigger than original.z-q
use_zopflistore_falsez*use quick, but not very good, compression.z--iterationsznumber of iterations, more iterations makes it slower but provides slightly better compression. Default: 15 for small files, 5 for large files.)defaulttyper   z	--filtersfilter_strategiesa  filter strategies to try: 0-4: give all scanlines PNG filter type 0-4; m: minimum sum; e: entropy; p: predefined (keep from input, this likely overlaps another strategy); b: brute force (experimental). By default, if this argument is not given, one that is most likely the best for this image is chosen by trying faster compression with each type. If this argument is used, all given filter types are tried with slow compression and the best result retained. A good set of filters to try is --filters=0me.)r   r   z--keepchunksc                 $    U R                  S5      $ )N,)split)ss    </var/www/html/env/lib/python3.13/site-packages/zopfli/png.py<lambda>main.<locals>.<lambda>L   s    qwws|    a  keep metadata chunks with these names that would normally be removed, e.g. tEXt,zTXt,iTXt,gAMA, ... Due to adding extra data, this increases the result size. Keeping bKGD or sBIT chunks may cause additional worse compression due to forcing a certain color type, it is advised to not keep these for web images because web browsers do not use these chunks. By default ZopfliPNG only keeps (and losslessly modifies) the following chunks because they are essential: IHDR, PLTE, tRNS, IDAT and IEND.)r   r   c                      g N )_s    r   r   r   Z   s    4r   )         rbzOptimizing )verboselossy_transparent
lossy_8bitr   
keepchunksr   num_iterationsnum_iterations_largezInput size: z (i   zK)d      zResult size: zK). Percentage of original: %zResult is smallerzResult has exact same sizezOriginal was smallerz,Preserving original PNG since it was smallerzFile z exists, overwrite? (y/N)
ywb)argparseosArgumentParseradd_argumentint
parse_argsr$   print
iterationsr   openr   readr   r%   r&   r   r'   r   lenroundalways_zopflifyr   pathisfiler   inputstriplowerwrite)argsr/   r0   parseroptionslogr(   r)   f	input_png
result_png
input_sizeresult_size
percentages                 r   mainrL      s   $$*@$AF
!
	"
k,EVW
K	   2	   J  
 E  
 W  
 9	   [    
=	  " #R	   %G??%C%070B0BB- 05,  aN A% 	gnnd	#qFFH	 
$ +gnn%&'!33%%!33%%%%%1
J YJ,zl"Z4%7$8;<j/K{/#5q9J
}B{d':&; <##-,a	1
  		"()""&'>?"J GGNN7??++E'//**EFGMMOUUW 	goot	$	
 
%	$] 
$	#\ 
%	$s   )L=L*
L'*
L8__main__r   )zopflizopfli.zopflir   r   __all__rL   __name__r   r   r   <module>rR      s-     2,M` zF r   