forked from anixart-mod/patcher
добавление вспомогательных функций, исправление добавления всплывающего окна первого запуска
This commit is contained in:
+14
-3
@@ -1,10 +1,12 @@
|
||||
"""Compress PNGs"""
|
||||
priority = 1
|
||||
|
||||
priority = -1
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def compress_pngs(root_dir):
|
||||
compressed_files = []
|
||||
for dirpath, _, filenames in os.walk(root_dir):
|
||||
@@ -14,14 +16,23 @@ def compress_pngs(root_dir):
|
||||
tqdm.write(f"Сжимаю: {filepath}")
|
||||
try:
|
||||
subprocess.run(
|
||||
["pngquant", "--force", "--ext", ".png", "--quality=65-90", filepath],
|
||||
check=True, capture_output=True
|
||||
[
|
||||
"pngquant",
|
||||
"--force",
|
||||
"--ext",
|
||||
".png",
|
||||
"--quality=65-90",
|
||||
filepath,
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
compressed_files.append(filepath)
|
||||
except subprocess.CalledProcessError as e:
|
||||
tqdm.write(f"Ошибка при сжатии {filepath}: {e}")
|
||||
return compressed_files
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
files = compress_pngs("./decompiled")
|
||||
return len(files) > 0 and any(files)
|
||||
|
||||
Reference in New Issue
Block a user