comparison mrjunejune/generate-icons.sh @ 241:9c2eec61a152

[assets] Generate site images as WebP with Bazel
author MrJuneJune <me@mrjunejune.com>
date Mon, 03 Aug 2026 11:26:30 -0700
parents 3b47e82ac57e
children
comparison
equal deleted inserted replaced
240:c345083cd8a7 241:9c2eec61a152
1 #!/bin/bash 1 #!/usr/bin/env bash
2 set -euo pipefail
2 3
3 # Generate PWA icons from SVG 4 workspace="$(hg root)"
4 # Requires ImageMagick: apt-get install imagemagick 5 cd "$workspace"
5 6
6 cd "$(dirname "$0")/src/public" 7 bazel build //mrjunejune:generated_webp_assets
7 8 echo "Generated WebP assets are under bazel-bin/mrjunejune/generated_webp/."
8 if ! command -v convert &> /dev/null; then
9 echo "❌ ImageMagick not found. Please install it:"
10 echo " Ubuntu/Debian: sudo apt-get install imagemagick"
11 echo " macOS: brew install imagemagick"
12 echo ""
13 echo "Or use an online tool: https://realfavicongenerator.net/"
14 exit 1
15 fi
16
17 echo "🎨 Generating PWA icons from epi_all_colors.svg..."
18
19 # 192x192 icon
20 echo " → Creating icon-192.png..."
21 convert epi_all_colors.svg -resize 192x192 -background none icon-192.png
22
23 # 512x512 icon
24 echo " → Creating icon-512.png..."
25 convert epi_all_colors.svg -resize 512x512 -background none icon-512.png
26
27 # Maskable icon (512x512 with safe zone - 80% of size)
28 echo " → Creating icon-maskable-512.png..."
29 convert epi_all_colors.svg -resize 409x409 -background none -gravity center -extent 512x512 icon-maskable-512.png
30
31 echo ""
32 echo "✅ Icons generated successfully!"
33 echo ""
34 echo "Generated files:"
35 echo " - icon-192.png"
36 echo " - icon-512.png"
37 echo " - icon-maskable-512.png"
38 echo ""
39 echo "Next steps:"
40 echo " 1. Verify icons look good: ls -lh src/public/icon-*.png"
41 echo " 2. Test PWA: Open site in Chrome → DevTools → Application → Manifest"
42 echo " 3. Run Lighthouse audit to check PWA score"