Compare commits
3 Commits
16f30e8d38
...
370cd80bbe
| Author | SHA1 | Date | |
|---|---|---|---|
| 370cd80bbe | |||
| ab62ce4f7b | |||
| dae74da39e |
@@ -0,0 +1,107 @@
|
|||||||
|
# PPTX Image Compressor – Installation Logic
|
||||||
|
|
||||||
|
## 1. Intro – One Line Summary
|
||||||
|
|
||||||
|
> The script selects the best available Python environment, falls back to a self-installed embedded runtime if necessary, ensures `pip`, installs `svg-polish` when possible, and runs the application with graceful degradation.
|
||||||
|
|
||||||
|
## 2. Lightweight Overview
|
||||||
|
|
||||||
|
```text
|
||||||
|
START
|
||||||
|
│
|
||||||
|
├─► Find usable Python
|
||||||
|
│ ├─ venv (active / local)
|
||||||
|
│ ├─ system Python
|
||||||
|
│ └─ fallback: download embedded Python
|
||||||
|
│
|
||||||
|
├─► Ensure pip works
|
||||||
|
│ ├─ pip exists → OK
|
||||||
|
│ ├─ ensurepip → try fix
|
||||||
|
│ └─ get-pip.py → fallback fix
|
||||||
|
│
|
||||||
|
├─► Install dependency
|
||||||
|
│ └─ svg-polish (optional but preferred)
|
||||||
|
│
|
||||||
|
├─► Run main script
|
||||||
|
│
|
||||||
|
└─► END
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Detailed Logic Tree
|
||||||
|
|
||||||
|
```text
|
||||||
|
START
|
||||||
|
│
|
||||||
|
├─► [A] Pre-check: caesiumclt
|
||||||
|
│ ├─ found → continue
|
||||||
|
│ └─ not found → EXIT
|
||||||
|
│
|
||||||
|
├─► [B] Python resolution (priority-based)
|
||||||
|
│ │
|
||||||
|
│ ├─ Active venv (VIRTUAL_ENV)?
|
||||||
|
│ │ └─ use it ✅
|
||||||
|
│ │
|
||||||
|
│ ├─ Local ".venv"?
|
||||||
|
│ │ └─ use it ✅
|
||||||
|
│ │
|
||||||
|
│ ├─ Local "venv"?
|
||||||
|
│ │ └─ use it ✅
|
||||||
|
│ │
|
||||||
|
│ ├─ System Python (python.exe, excluding WindowsApps)?
|
||||||
|
│ │ └─ use it ✅
|
||||||
|
│ │
|
||||||
|
│ ├─ Python launcher (py.exe)?
|
||||||
|
│ │ └─ use py -3 ✅
|
||||||
|
│ │
|
||||||
|
│ ├─ Existing embedded Python?
|
||||||
|
│ │ └─ use it ✅
|
||||||
|
│ │
|
||||||
|
│ └─ NONE FOUND →
|
||||||
|
│ ├─ Download embeddable Python
|
||||||
|
│ ├─ Extract to python-embed
|
||||||
|
│ ├─ Fix isolation (enable "import site")
|
||||||
|
│ └─ use it ✅
|
||||||
|
│
|
||||||
|
├─► [C] Validate main script exists
|
||||||
|
│ ├─ missing → EXIT
|
||||||
|
│ └─ exists → continue
|
||||||
|
│
|
||||||
|
├─► [D] Ensure pip availability
|
||||||
|
│ │
|
||||||
|
│ ├─ pip works?
|
||||||
|
│ │ └─ YES → continue ✅
|
||||||
|
│ │
|
||||||
|
│ └─ NO →
|
||||||
|
│ ├─ try: ensurepip
|
||||||
|
│ │ ├─ success → ✅
|
||||||
|
│ │ └─ fail →
|
||||||
|
│ │
|
||||||
|
│ └─ if embedded Python:
|
||||||
|
│ ├─ download get-pip.py
|
||||||
|
│ ├─ execute it
|
||||||
|
│ ├─ remove file
|
||||||
|
│ └─ re-check pip
|
||||||
|
│
|
||||||
|
│ ├─ still no pip →
|
||||||
|
│ │ └─ WARN: disable SVG compression
|
||||||
|
│ │
|
||||||
|
│ └─ pip available →
|
||||||
|
│ ✅ continue
|
||||||
|
│
|
||||||
|
├─► [E] Install dependency
|
||||||
|
│ ├─ install svg-polish
|
||||||
|
│ │ ├─ success → ✅ SVG enabled
|
||||||
|
│ │ └─ fail → ⚠ SVG disabled
|
||||||
|
│ │
|
||||||
|
│ └─ optional debug: pip list
|
||||||
|
│
|
||||||
|
├─► [F] Run application
|
||||||
|
│ ├─ execute Python script
|
||||||
|
│ ├─ capture return code
|
||||||
|
│ ├─ success → "Fertig"
|
||||||
|
│ └─ error → report exit code
|
||||||
|
│
|
||||||
|
└─► END
|
||||||
|
```
|
||||||
@@ -829,8 +829,9 @@ def extractParserArguments():
|
|||||||
parser.add_argument('-O','--output-dir', help='Output-Verzeichnis (erforderlich für Batch)')
|
parser.add_argument('-O','--output-dir', help='Output-Verzeichnis (erforderlich für Batch)')
|
||||||
parser.add_argument('--pattern', default='*.pptx', help='Dateimuster für --input-dir')
|
parser.add_argument('--pattern', default='*.pptx', help='Dateimuster für --input-dir')
|
||||||
parser.add_argument('--recursive', action='store_true', help='Rekursiv in --input-dir suchen')
|
parser.add_argument('--recursive', action='store_true', help='Rekursiv in --input-dir suchen')
|
||||||
#parser.add_argument('-t','--threads', type=int, default=min(32, os.cpu_count() or 4), help='Anzahl paralleler Threads pro Datei')
|
# Standard as of https://docs.python.org/3/library/concurrent.futures.html. Changed in version 3.13: Default value of max_workers is changed to min(32, (os.process_cpu_count() or 1) + 4).
|
||||||
parser.add_argument('-t','--threads', type=int, default=16, help='Anzahl paralleler Threads pro Datei')
|
# On my machine this is 16 Threads
|
||||||
|
parser.add_argument('-t','--threads', type=int, default=min(32, (os.process_cpu_count() or 1) + 4), help='Anzahl paralleler Threads pro Datei')
|
||||||
parser.add_argument('-q','--quality', type=int, default=90, help='Qualität für caesiumclt (0..100), höher = bessere Qualität / größere Datei')
|
parser.add_argument('-q','--quality', type=int, default=90, help='Qualität für caesiumclt (0..100), höher = bessere Qualität / größere Datei')
|
||||||
parser.add_argument('--min-savings', default=DEFAULT_MIN_SAVINGS, help="Mindestersparnis für caesiumclt (z. B. 2%%, 100KB, 1MB oder Bytes als Zahl)")
|
parser.add_argument('--min-savings', default=DEFAULT_MIN_SAVINGS, help="Mindestersparnis für caesiumclt (z. B. 2%%, 100KB, 1MB oder Bytes als Zahl)")
|
||||||
parser.add_argument('--svg-profile', choices=[SVG_PROFILE_BALANCED, SVG_PROFILE_AGGRESSIVE], default=SVG_PROFILE_DEFAULT, help='Optimierungsprofil für SVG-Kompression')
|
parser.add_argument('--svg-profile', choices=[SVG_PROFILE_BALANCED, SVG_PROFILE_AGGRESSIVE], default=SVG_PROFILE_DEFAULT, help='Optimierungsprofil für SVG-Kompression')
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ if "%~1"=="" goto help
|
|||||||
|
|
||||||
set "INPUT=%~1"
|
set "INPUT=%~1"
|
||||||
set "EXT=%~x1"
|
set "EXT=%~x1"
|
||||||
|
set "PATH=%PATH%;%~dp0"
|
||||||
|
|
||||||
if /I not "%EXT%"==".pptx" (
|
if /I not "%EXT%"==".pptx" (
|
||||||
echo [ERROR] Only .pptx supported
|
echo [ERROR] Only .pptx supported
|
||||||
@@ -12,18 +13,20 @@ if /I not "%EXT%"==".pptx" (
|
|||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
set "OUT=%~dp1%~n1_compressed.pptx"
|
|
||||||
|
|
||||||
echo [INFO] Compressing %~n1
|
echo [INFO] Compressing %~n1
|
||||||
|
|
||||||
"%~dp0pptx-image-compress.exe" -i "%INPUT%" -o "%OUT%"
|
rem optional: ensure correct working dir
|
||||||
|
pushd "%~dp0"
|
||||||
|
|
||||||
|
"%~dp0pptx-image-compress.exe" -i "%INPUT%"
|
||||||
set RC=%ERRORLEVEL%
|
set RC=%ERRORLEVEL%
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
if %RC% neq 0 (
|
if %RC% neq 0 (
|
||||||
echo [ERROR] Failed (%RC%)
|
echo [ERROR] Failed (%RC%)
|
||||||
) else (
|
) else (
|
||||||
echo [SUCCESS] Done
|
echo [SUCCESS] Done
|
||||||
echo Output: "%OUT%"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
pause
|
pause
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ if "%~1"=="" (
|
|||||||
) else (
|
) else (
|
||||||
"%~dp0pptx-image-compress.exe" %*
|
"%~dp0pptx-image-compress.exe" %*
|
||||||
)
|
)
|
||||||
``
|
|
||||||
Reference in New Issue
Block a user