Alle UNICODE Characters zu ASCII verändert

This commit is contained in:
2025-09-22 13:27:17 +02:00
parent eff926a443
commit 88d3793c70
2 changed files with 16 additions and 17 deletions

View File

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""
PPTX Grafik-Komprimier-Tool (nur CaesiumCLT, Multi-Thread, Batch, sauberes Cleanup)
Version: 1.1.2
Version: 1.1.3
Highlights:
@@ -12,9 +12,8 @@ Highlights:
- Log: image_name,size_before,size_after,saving,saving_percent
- Summary inkl. Zeit benötigt
Änderungen in 1.1.2:
- Batch Mode hinzugefügt
- Shellscript-Fix (Store-Alias vermeiden) und Doku-Anpassungen
Änderungen in 1.1.3:
- Changed all UNICODE Chars to ASCII
"""
import argparse
@@ -32,7 +31,7 @@ from datetime import timedelta
from concurrent.futures import ThreadPoolExecutor, as_completed
from threading import Lock
__version__ = "1.1.2"
__version__ = "1.1.3"
ALLOWED_EXT = {".jpg", ".jpeg", ".png", ".webp", ".gif"} # GIF wird übersprungen
PROGRESS_BAR_LEN = 40
@@ -89,7 +88,7 @@ def which(cmd: str):
def compress_with_caesium(original: Path, out_dir: Path, caesium_threads: int | None, quality: int) -> Path | None:
exe = which("caesiumclt")
if not exe:
raise RuntimeError(" 'caesiumclt' wurde nicht gefunden. Bitte CaesiumCLT installieren und in PATH verfügbar machen.")
raise RuntimeError("[ERROR] 'caesiumclt' wurde nicht gefunden. Bitte CaesiumCLT installieren und in PATH verfügbar machen.")
out_dir.mkdir(parents=True, exist_ok=True)
ext = original.suffix.lower()
if ext not in {".jpg", ".jpeg", ".png", ".webp"}:
@@ -160,7 +159,7 @@ def process_single_deck(input_pptx: Path, output_pptx: Path, threads: int, quali
images.append(f)
total = len(images)
print(f"🔧 {input_pptx.name}: {total} Bild(er) gefunden")
print(f"[Processing] {input_pptx.name}: {total} Bild(er) gefunden")
print_progress(0, total)
if not which("caesiumclt"):
@@ -241,8 +240,8 @@ def process_single_deck(input_pptx: Path, output_pptx: Path, threads: int, quali
result["ok"] = True
savings_pct = 0.0 if size_before == 0 else round(100.0 * (size_before - size_after) / size_before, 2)
print(f" Fertig! ({input_pptx.name})")
print("📋 Zusammenfassung ----------------")
print(f"[OK] Fertig! ({input_pptx.name})")
print("Zusammenfassung ----------------")
print(" Vorher: ", human_mb(size_before), "MB")
print(" Nachher: ", human_mb(size_after), "MB")
print(" Ersparnis: ", f"{savings_pct}%")
@@ -333,7 +332,7 @@ def main():
print("Threads used: ", args.threads," Threads")
if args.quality < 0 or args.quality > 100:
print(' Ungültige Qualität. Erlaubt: 0..100')
print('[ERROR] Ungültige Qualität. Erlaubt: 0..100')
sys.exit(1)
input_files: list[Path] = []
@@ -349,11 +348,11 @@ def main():
batch_mode = len(input_files) > 1
if batch_mode and not args.output_dir:
print(' Batch-Modus erkannt. Bitte -O/--output-dir angeben.')
print('[ERROR] Batch-Modus erkannt. Bitte -O/--output-dir angeben.')
sys.exit(2)
if not which('caesiumclt'):
print(" 'caesiumclt' nicht gefunden. Bitte installieren und in PATH verfügbar machen.")
print("[ERROR] 'caesiumclt' nicht gefunden. Bitte installieren und in PATH verfügbar machen.")
sys.exit(3)
overall_before = 0
@@ -364,7 +363,7 @@ def main():
if batch_mode:
out_dir = Path(args.output_dir).resolve()
out_dir.mkdir(parents=True, exist_ok=True)
print(f"🗂️ Batch: {len(input_files)} Datei(en). Output-Verzeichnis: {out_dir}")
print(f"Batch: {len(input_files)} Datei(en). Output-Verzeichnis: {out_dir}")
for src in input_files:
if not src.exists():
print(f"- Übersprungen (nicht gefunden): {src}")
@@ -397,11 +396,11 @@ def main():
if batch_mode:
print(f"====== 📊 Gesamt-Summary ======")
print(f" Dateien erfolgreich: {successes}")
print(f"====== Gesamt-Summary ======")
print(f"[SUCCESS] Dateien erfolgreich: {successes}")
if failures > 0:
print(f"Dateien fehlgeschlagen: {failures}")
print(f"[FAILED] Dateien fehlgeschlagen: {failures}")
if overall_before > 0:
pct = round(100.0 * (overall_before - overall_after) / overall_before, 2)