#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
FIG="../FigmaDoc/Web Insanity.fig"
OUT="assets-src"
rm -rf "$OUT" && mkdir -p "$OUT"
unzip -o -j -q "$FIG" 'images/*' -d "$OUT"
cd "$OUT"
for f in *; do
  case "$(file --brief --mime-type "$f")" in
    image/png)  mv "$f" "$f.png" ;;
    image/jpeg) mv "$f" "$f.jpg" ;;
    image/webp) mv "$f" "$f.webp" ;;
    *) rm -f "$f" ;;
  esac
done
echo "Estratte: $(ls | wc -l) immagini in $OUT/"
