election-game/art/gen-card.sh

20 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/zsh
# 用本機 codex 的生圖工具產生一張卡牌插圖:gen-card.sh <id> <題材>
# 原圖存 art/generated/<id>.png,網頁用的縮圖存 web/public/cards/<id>.webp
set -u
id="$1"; subject="$2"
here="${0:A:h}"
out="$here/generated/$id.png"
web="$here/../web/public/cards/$id.webp"
style="Style: tabletop board-game card illustration, miniature diorama look with tilt-shift depth of field, soft isometric three-quarter top-down view, warm gouache texture, clean readable shapes, cohesive warm palette with a few saturated accents. Setting: present-day Taiwan. Absolutely no text, no letters, no numbers, no logos, no party symbols or party colors on flags (flags and banners are plain), no real or recognizable people; all figures are small, anonymous and stylized. Square 1024x1024."
if [[ ! -s "$out" ]]; then
codex exec --skip-git-repo-check --sandbox workspace-write -C "$here/generated" \
"Use your image generation tool to create ONE image and save it as $id.png in the current directory (overwrite if it exists). Subject: $subject. $style After saving, print the absolute path of the file and nothing else." \
> "$here/generated/$id.log" 2>&1
fi
if [[ -s "$out" ]]; then
cwebp -quiet -q 80 -resize 640 640 "$out" -o "$web" && echo "ok $id"
else
echo "FAIL $id"
fi