#!/usr/bin/env bash # Regenerate every app icon from assets/app-icon/designcraft.svg. # # Needs: resvg (brew install resvg / cargo install resvg). On macOS, iconutil also writes the # .icns. The outputs are committed, so builds and packaging never need these tools. # # packaging/icons.sh set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DIR="$ROOT/assets/app-icon" SVG="$DIR/designcraft.svg" ID="ai.storyteller.designcraft" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT command -v resvg >/dev/null || { echo "error: resvg not found (brew install resvg)" >&2; exit 1; } # The artwork is a full-bleed 512 tile (rx=112). Windows and Linux use it as is. macOS icons sit on # Apple's grid: an 824/1024 body with a transparent margin, so widen the viewBox to 512*1024/824. MAC="$TMP/mac.svg" sed 's/viewBox="0 0 512 512"/viewBox="-62.136 -62.136 636.272 636.272"/' "$SVG" >"$MAC" grep -q 'viewBox="-62.136' "$MAC" || { echo "error: expected viewBox=\"0 0 512 512\" in $SVG" >&2; exit 1; } render() { resvg -w "$2" -h "$2" "$1" "$3" /dev/null; then SET="$TMP/designcraft.iconset" mkdir -p "$SET" for s in 16 32 128 256 512; do render "$MAC" "$s" "$SET/icon_${s}x${s}.png" render "$MAC" $((s * 2)) "$SET/icon_${s}x${s}@2x.png" done iconutil -c icns -o "$DIR/designcraft.icns" "$SET" else echo "warning: iconutil not found (macOS only); designcraft.icns not regenerated" >&2 fi echo "icons written to $DIR"