#!/bin/sh
# Regenerate the PNG app icons in www/ from www/logo.svg (only needed when the
# logo changes; the PNGs are committed). Needs inkscape, plus python3 with
# Pillow to recompress the files.
set -e
cd "$(dirname "$0")/www"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
# full-bleed square with the artwork inside the 80% safe zone, for Android's
# maskable icon and the iOS home screen (both round the corners themselves)
sed -e 's|||' \
-e 's|||' logo.svg > "$tmp/full.svg"
inkscape logo.svg -w 192 -o icon-192.png
inkscape "$tmp/full.svg" -w 512 -o icon-maskable-512.png
inkscape "$tmp/full.svg" -w 180 -o apple-touch-icon.png
python3 - <<'EOF'
from PIL import Image
for f in ("icon-192.png", "icon-maskable-512.png", "apple-touch-icon.png"):
Image.open(f).convert("RGBA").save(f, optimize=True)
EOF
ls -l icon-*.png apple-touch-icon.png