Files
2026-06-12 15:00:15 +08:00

24 lines
955 B
Bash

#!/usr/bin/env bash
# 从 SVG 生成 PWA 所需 PNG 图标(Chrome 安装条件)
# 用法: bash scripts/gen_pwa_icons.sh
set -euo pipefail
cd "$(dirname "$0")/../pwa/icons"
SVG="icon.svg"
if command -v rsvg-convert &>/dev/null; then
rsvg-convert -w 192 -h 192 "${SVG}" -o icon-192.png
rsvg-convert -w 512 -h 512 "${SVG}" -o icon-512.png
elif command -v convert &>/dev/null; then
convert -background none "${SVG}" -resize 192x192 icon-192.png
convert -background none "${SVG}" -resize 512x512 icon-512.png
elif command -v ffmpeg &>/dev/null; then
ffmpeg -y -f lavfi -i "color=c=0x0f1419:s=512x512" -frames:v 1 icon-512.png 2>/dev/null
ffmpeg -y -f lavfi -i "color=c=0x0f1419:s=192x192" -frames:v 1 icon-192.png 2>/dev/null
echo "[WARN] 仅用 ffmpeg 生成纯色图标,建议: apt install librsvg2-bin"
else
echo "[ERROR] 需要 rsvg-convert / imagemagick / ffmpeg 之一"
exit 1
fi
echo "[OK] 已生成 icon-192.png icon-512.png"