From db77a977e6e57ddd8288d9a82c76104d7d1cfed7 Mon Sep 17 00:00:00 2001 From: Frank Conrads Date: Thu, 11 Sep 2025 14:35:22 +0200 Subject: [PATCH] Log-Format in KB --- pptx_image_compress.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pptx_image_compress.py b/pptx_image_compress.py index d18a8af..0ec2407 100644 --- a/pptx_image_compress.py +++ b/pptx_image_compress.py @@ -43,6 +43,9 @@ TEMP_PREFIX = "pptx_compress_" def human_mb(nbytes: int) -> float: return round(nbytes / (1024 * 1024), 2) +def human_kb(nbytes: int) -> float: + return round(nbytes / 1024,2) + def ensure_clean_file(path: Path): if path.exists(): try: @@ -141,7 +144,7 @@ def process_single_deck(input_pptx: Path, output_pptx: Path, threads: int, quali log_file = output_pptx.with_suffix(".log.csv") ensure_clean_file(log_file) - log_lines = ["image_name;size_before;size_after;saving;saving_percent\n"] + log_lines = ["image_name;size_before(kb);size_after(kb);saving(kb);saving_percent(%)\n"] size_before = input_pptx.stat().st_size result["size_before"] = size_before @@ -174,7 +177,7 @@ def process_single_deck(input_pptx: Path, output_pptx: Path, threads: int, quali if ext == ".gif": with lock: done_count += 1 - log_lines.append(f"{img_path.name};{orig_size};{orig_size};0;0.0\n") + log_lines.append(f"{img_path.name};{human_kb(orig_size)};{human_kb(orig_size)};0;0.0\n") print_progress(done_count, total) return chosen_size = orig_size @@ -194,7 +197,7 @@ def process_single_deck(input_pptx: Path, output_pptx: Path, threads: int, quali saving = orig_size - chosen_size saving_percent = round((saving / orig_size) * 100, 2) if orig_size > 0 else 0.0 with lock: - log_lines.append(f"{img_path.name};{orig_size};{chosen_size};{saving};{saving_percent}\n") + log_lines.append(f"{img_path.name};{human_kb(orig_size)};{human_kb(chosen_size)};{human_kb(saving)};{saving_percent}\n") done_count += 1 print_progress(done_count, total)