From da63e0038576af5a5fe7c99fe81dad8d62f2c3e7 Mon Sep 17 00:00:00 2001 From: Llloooggg Date: Wed, 14 May 2025 00:57:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B0=D0=B2=D0=B1=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BB=D0=BE=D0=B3=D0=B8=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=89=D0=B5=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- image_compressor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/image_compressor.py b/image_compressor.py index b6003fd..5e1f362 100644 --- a/image_compressor.py +++ b/image_compressor.py @@ -22,7 +22,7 @@ logging.basicConfig( format="%(asctime)s - %(message)s", ) -MIN_SIZE = 1.5 * 1024 * 1024 +MIN_SIZE = 2 * 1024 * 1024 TARGET_SIZE_MB = 1.5 * 1024 * 1024 MAX_WORKERS = min(32, (multiprocessing.cpu_count() or 1) * 5) @@ -155,7 +155,6 @@ def compress_with_external(path: str, ext: str) -> bool: def compress_with_pillow(path: str) -> bool: - ext = Path(path).suffix.lower() original_size = os.path.getsize(path) target_size = TARGET_SIZE_MB temp_path = Path(path).with_suffix(".pillowtmp") @@ -197,6 +196,8 @@ def compress_image(path: str, fallback_to_pillow: bool = False): original_size = os.path.getsize(path) if original_size < MIN_SIZE: skipped_count += 1 + msg = f"Пропущено (уже малый): {path} ({original_size / 1024:.1f} KB)" + logging.info(msg) return h = file_hash(path) @@ -204,6 +205,8 @@ def compress_image(path: str, fallback_to_pillow: bool = False): cursor.execute("SELECT 1 FROM processed WHERE hash = ?", (h,)) if cursor.fetchone(): skipped_count += 1 + msg = f"Пропущено (уже сжато): {path} ({original_size / 1024:.1f} KB)" + logging.info(msg) return ext = Path(path).suffix.lower()