From 0a94506e78210a3319a49328d98c02186a9c6c81 Mon Sep 17 00:00:00 2001 From: padreug Date: Sat, 11 Oct 2025 07:00:50 +0200 Subject: [PATCH] initial commit --- TODO.md | 1 + make-pwa-images.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 TODO.md create mode 100755 make-pwa-images.sh diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..73c751d --- /dev/null +++ b/TODO.md @@ -0,0 +1 @@ +- [ ] get the script to copy the original file to logo.png diff --git a/make-pwa-images.sh b/make-pwa-images.sh new file mode 100755 index 0000000..143d05c --- /dev/null +++ b/make-pwa-images.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Minimal PWA icon generator (no manifest/html) +# Outputs: icon-192.png, icon-512.png, icon-maskable-192.png, icon-maskable-512.png, +# apple-touch-icon.png (180x180), favicon.ico (16/32/48) + +# Detect ImageMagick binary +if command -v magick >/dev/null 2>&1; then + IM="magick" +elif command -v convert >/dev/null 2>&1; then + IM="convert" +else + echo "Error: ImageMagick not found (need 'magick' or 'convert')." >&2 + exit 1 +fi + +if [[ $# -lt 2 ]]; then + echo "Usage: $0 " + exit 1 +fi + +SRC="$1" +OUT="${2%/}" +mkdir -p "$OUT" + +make_png() { + local size="$1" dest="$2" + $IM "$SRC" \ + -alpha on -background none \ + -resize "${size}x${size}" \ + -gravity center -extent "${size}x${size}" \ + "PNG32:${dest}" +} + +make_maskable() { + local size="$1" dest="$2" + local inner=$(((size * 70) / 100)) + $IM "$SRC" \ + -alpha on -background none \ + -resize "${inner}x${inner}" \ + -gravity center -extent "${size}x${size}" \ + "PNG32:${dest}" +} + +echo "→ Generating core icons..." +make_png 192 "$OUT/icon-192.png" +make_png 512 "$OUT/icon-512.png" +make_maskable 192 "$OUT/icon-maskable-192.png" +make_maskable 512 "$OUT/icon-maskable-512.png" +make_png 180 "$OUT/apple-touch-icon.png" + +echo "→ Generating favicon.ico..." +tmpdir="$(mktemp -d)" +trap 'rm -rf "$tmpdir"' EXIT + +for s in 16 32 48; do + $IM "$SRC" -alpha on -background none \ + -resize "${s}x${s}" \ + -gravity center -extent "${s}x${s}" \ + "PNG32:${tmpdir}/${s}.png" +done + +$IM "${tmpdir}/16.png" "${tmpdir}/32.png" "${tmpdir}/48.png" "$OUT/favicon.ico" + +echo "✅ Done. Wrote minimal PWA icons to: $OUT"