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>
38 lines
1.7 KiB
PowerShell
38 lines
1.7 KiB
PowerShell
# Avatar-Thumbnails generieren — original PNGs bleiben, Thumbs als WebP 256x256.
|
|
# Idempotent. Re-Run: powershell -ExecutionPolicy Bypass -File "App\Don_t_Deploy\build-avatar-thumbs.ps1"
|
|
$ErrorActionPreference = 'Stop'
|
|
$src = Join-Path $PSScriptRoot '..\assets\img\avatars'
|
|
$dst = Join-Path $src 'thumbs'
|
|
if (-not (Test-Path $dst)) { New-Item -ItemType Directory -Path $dst | Out-Null }
|
|
$mg = (Get-Command magick -ErrorAction SilentlyContinue).Source
|
|
if (-not $mg) {
|
|
$candidate = 'C:\Program Files\ImageMagick-7.1.2-Q16-HDRI\magick.exe'
|
|
if (Test-Path $candidate) { $mg = $candidate }
|
|
}
|
|
if (-not $mg) { Write-Error 'ImageMagick fehlt'; exit 1 }
|
|
$created = 0; $skipped = 0; $failed = 0; $origSize = 0; $thumbSize = 0
|
|
Get-ChildItem -Path $src -Filter 'avatar-*.png' | ForEach-Object {
|
|
$orig = $_.FullName
|
|
$thumb = Join-Path $dst ([System.IO.Path]::GetFileNameWithoutExtension($_.Name) + '.webp')
|
|
$origSize += $_.Length
|
|
if ((Test-Path $thumb) -and ((Get-Item $thumb).LastWriteTime -gt $_.LastWriteTime)) {
|
|
$thumbSize += (Get-Item $thumb).Length
|
|
$skipped++
|
|
return
|
|
}
|
|
& $mg $orig -resize '256x256^' -gravity center -extent 256x256 -quality 82 $thumb
|
|
if ($LASTEXITCODE -eq 0 -and (Test-Path $thumb)) {
|
|
$thumbSize += (Get-Item $thumb).Length
|
|
$created++
|
|
Write-Host (' ok ' + $_.Name)
|
|
} else {
|
|
$failed++
|
|
Write-Warning (' fail ' + $_.Name)
|
|
}
|
|
}
|
|
$origMB = [math]::Round($origSize / 1MB, 2)
|
|
$thumbKB = [math]::Round($thumbSize / 1KB, 1)
|
|
Write-Host ''
|
|
Write-Host ('Thumbs erstellt: ' + $created + ' neu, ' + $skipped + ' geskippt, ' + $failed + ' Fehler')
|
|
Write-Host ('Originale: ' + $origMB + ' MB | Thumbs: ' + $thumbKB + ' KB')
|