#!/bin/zsh
set -euo pipefail

pack_dir=${0:A:h}
for source in "$pack_dir"/card-*.svg; do
  sips -s format png "$source" --out "${source:r}.png" >/dev/null
done

ffmpeg -hide_banner -loglevel error -y \
  -framerate 1 -pattern_type glob -i "$pack_dir/card-*.png" \
  -vf "scale=405:506:force_original_aspect_ratio=decrease,pad=405:506:-1:-1:color=0x0f1020,tile=2x2:padding=24:margin=24:color=0x0f1020" \
  -frames:v 1 "$pack_dir/contact-sheet.png"
