1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
94 lines
3.0 KiB
PowerShell
94 lines
3.0 KiB
PowerShell
# Build-Schritt: Glossar-Thumbnails als WebP generieren
|
|
# Quelle: App/assets/img/glossar/*.png, *.jpg
|
|
# Ziel: App/assets/img/glossar/thumbs/*.webp (480x270, q=75)
|
|
# Skip-Regel: Thumb existiert UND ist neuer als Original
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$magick = 'C:\Program Files\ImageMagick-7.1.2-Q16-HDRI\magick.exe'
|
|
if (-not (Test-Path $magick)) {
|
|
# Fallback: PATH (falls neuere Version installiert)
|
|
$cmd = Get-Command magick -ErrorAction SilentlyContinue
|
|
if ($cmd) { $magick = $cmd.Source }
|
|
else {
|
|
Write-Error "ImageMagick nicht gefunden. Installation: winget install ImageMagick.ImageMagick"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
$srcDir = 'C:\xampp\htdocs\geograsim\App\assets\img\glossar'
|
|
$thumbDir = Join-Path $srcDir 'thumbs'
|
|
|
|
if (-not (Test-Path $thumbDir)) {
|
|
New-Item -ItemType Directory -Path $thumbDir | Out-Null
|
|
Write-Host "Thumbs-Ordner angelegt: $thumbDir"
|
|
}
|
|
|
|
$sources = Get-ChildItem -Path $srcDir -File | Where-Object { $_.Extension -match '^\.(png|jpg|jpeg)$' }
|
|
|
|
$total = $sources.Count
|
|
$generated = 0
|
|
$skipped = 0
|
|
$failed = 0
|
|
$sumSrcBytes = 0
|
|
$sumDstBytes = 0
|
|
|
|
Write-Host ""
|
|
Write-Host "Quelle: $srcDir"
|
|
Write-Host "Ziel: $thumbDir"
|
|
Write-Host "Files: $total PNG/JPG gefunden"
|
|
Write-Host ('-' * 60)
|
|
|
|
foreach ($src in $sources) {
|
|
$base = [System.IO.Path]::GetFileNameWithoutExtension($src.Name)
|
|
$dstPath = Join-Path $thumbDir "$base.webp"
|
|
|
|
$needBuild = $true
|
|
if (Test-Path $dstPath) {
|
|
$dst = Get-Item $dstPath
|
|
if ($dst.LastWriteTime -ge $src.LastWriteTime) {
|
|
$needBuild = $false
|
|
}
|
|
}
|
|
|
|
if (-not $needBuild) {
|
|
$skipped++
|
|
$sumSrcBytes += $src.Length
|
|
$sumDstBytes += (Get-Item $dstPath).Length
|
|
Write-Host ("[SKIP] {0} (Thumb aktuell)" -f $src.Name)
|
|
continue
|
|
}
|
|
|
|
try {
|
|
& $magick $src.FullName -resize '480x270^' -gravity center -extent 480x270 -quality 75 $dstPath
|
|
if ($LASTEXITCODE -ne 0) { throw "magick exit $LASTEXITCODE" }
|
|
|
|
$dstSize = (Get-Item $dstPath).Length
|
|
$srcSize = $src.Length
|
|
$reduce = [math]::Round((1 - $dstSize / $srcSize) * 100, 1)
|
|
$sumSrcBytes += $srcSize
|
|
$sumDstBytes += $dstSize
|
|
$generated++
|
|
Write-Host ("[GEN] {0,-45} {1,8:N0} B -> {2,7:N0} B (-{3}%)" -f $src.Name, $srcSize, $dstSize, $reduce)
|
|
}
|
|
catch {
|
|
$failed++
|
|
Write-Host ("[FAIL] {0} -- {1}" -f $src.Name, $_.Exception.Message) -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Write-Host ('-' * 60)
|
|
$srcMB = [math]::Round($sumSrcBytes / 1MB, 2)
|
|
$dstMB = [math]::Round($sumDstBytes / 1MB, 2)
|
|
$pct = if ($sumSrcBytes -gt 0) { [math]::Round((1 - $sumDstBytes / $sumSrcBytes) * 100, 1) } else { 0 }
|
|
|
|
Write-Host ""
|
|
Write-Host ("Generiert : {0}" -f $generated)
|
|
Write-Host ("Skipped : {0}" -f $skipped)
|
|
Write-Host ("Failed : {0}" -f $failed)
|
|
Write-Host ("Total : {0} / {1}" -f ($generated + $skipped + $failed), $total)
|
|
Write-Host ""
|
|
Write-Host ("Originale : {0} MB" -f $srcMB)
|
|
Write-Host ("Thumbs : {0} MB" -f $dstMB)
|
|
Write-Host ("Ersparnis : -{0}%" -f $pct)
|