Log-Format in KB

This commit is contained in:
2025-09-11 14:35:22 +02:00
parent 01455784e2
commit db77a977e6

View File

@@ -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)