← back to Wallco Ai

scripts/backfill_drunk_animals.sh

44 lines

#!/bin/zsh
# Backfill seamless + watermark on the 26 drunk-animal designs that were
# generated before the launchd PATH fix made /opt/homebrew/bin/python3
# (the one with PIL/Pillow) available. Each design gets:
#   1. scripts/make_seamless.py  — collapse edge-pixel delta for tileability
#   2. scripts/watermark.py embed — triple-layer SAND, LLC copyright
#
# Idempotent — both scripts overwrite in-place; running twice is harmless.

ROOT=/Users/macstudio3/Projects/wallco-ai
PSQL=/opt/homebrew/opt/postgresql@14/bin/psql
PY=/opt/homebrew/bin/python3
cd "$ROOT"

IDS=(1514 1515 1516 1517 1520 1523 1525 1527 1528 1529 1530 1531 1532 1533 \
     1534 1535 1536 1537 1538 1539 1558 1567 1578 1585 1592 1602)

ok=0
fail=0
YEAR=$(/bin/date +%Y)

for id in "${IDS[@]}"; do
  path=$("$PSQL" dw_unified -At -c "SELECT local_path FROM spoon_all_designs WHERE id=$id;" 2>/dev/null)
  if [[ -z "$path" || ! -f "$path" ]]; then
    echo "  ✗ #$id missing file (path='$path')"
    fail=$((fail+1))
    continue
  fi
  "$PY" scripts/make_seamless.py "$path" "$path" >/dev/null 2>/tmp/wms_seam.err
  seam=$?
  "$PY" scripts/watermark.py embed "$path" --out "$path" --owner "SAND, LLC" --year "$YEAR" >/dev/null 2>/tmp/wms_wm.err
  wm=$?
  if [[ $wm -eq 0 ]]; then
    ok=$((ok+1))
    echo "  ✓ #$id watermarked (seamless=$seam)"
  else
    fail=$((fail+1))
    echo "  ✗ #$id watermark exit=$wm: $(/usr/bin/head -1 /tmp/wms_wm.err)"
  fi
done

echo ""
echo "Backfill done — $ok ok, $fail failed"