Log-Format in KB
This commit is contained in:
@@ -43,6 +43,9 @@ TEMP_PREFIX = "pptx_compress_"
|
|||||||
def human_mb(nbytes: int) -> float:
|
def human_mb(nbytes: int) -> float:
|
||||||
return round(nbytes / (1024 * 1024), 2)
|
return round(nbytes / (1024 * 1024), 2)
|
||||||
|
|
||||||
|
def human_kb(nbytes: int) -> float:
|
||||||
|
return round(nbytes / 1024,2)
|
||||||
|
|
||||||
def ensure_clean_file(path: Path):
|
def ensure_clean_file(path: Path):
|
||||||
if path.exists():
|
if path.exists():
|
||||||
try:
|
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")
|
log_file = output_pptx.with_suffix(".log.csv")
|
||||||
ensure_clean_file(log_file)
|
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
|
size_before = input_pptx.stat().st_size
|
||||||
result["size_before"] = size_before
|
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":
|
if ext == ".gif":
|
||||||
with lock:
|
with lock:
|
||||||
done_count += 1
|
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)
|
print_progress(done_count, total)
|
||||||
return
|
return
|
||||||
chosen_size = orig_size
|
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 = orig_size - chosen_size
|
||||||
saving_percent = round((saving / orig_size) * 100, 2) if orig_size > 0 else 0.0
|
saving_percent = round((saving / orig_size) * 100, 2) if orig_size > 0 else 0.0
|
||||||
with lock:
|
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
|
done_count += 1
|
||||||
print_progress(done_count, total)
|
print_progress(done_count, total)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user