Files
geograsim/App/Don_t_Deploy/generate-article-covers.sh
Adminator 1e51ef7def Nachtrag: alle bisher untracked Ordner + hängende Änderungen mit-committen
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/
- 12 code-workspace-Files
- STATUS-*.md
- viele M/D/R-Änderungen an bereits getrackten Files
- .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-08 02:27:02 +02:00

51 lines
3.2 KiB
Bash

#!/usr/bin/env bash
# Cover-Bilder fuer die zwei Fachartikel auf der Landing-Page.
# Stil: Flat Scandinavian Illustration (verbindlich, siehe Memory).
#
# Aufruf:
# set -a; source App/.env.local; set +a
# bash App/Don_t_Deploy/generate-article-covers.sh
set -e
: "${OPENAI_API_KEY:?Env-Variable OPENAI_API_KEY muss gesetzt sein}"
OUT="$(cd "$(dirname "$0")/../assets/img/articles" && pwd)"
cd "$OUT"
PROMPT_BASE="Flat Scandinavian illustration, wide panoramic landscape filling the entire 16:9 frame edge-to-edge, painted style with clean vector shapes, dark forest green (#1f4b37) and sage green (#4a7c4e) tones, yellow-mustard (#e8c547) accents, beige (#e8e4d8) buildings and valleys, white highlights. No text, no watermark, no logos, no borders, no frame."
declare -A PROMPTS=(
[lernen-durch-simulation]="$PROMPT_BASE Scene: A bright modern classroom seen from a slight angle, two or three young students sitting at wooden desks, looking thoughtfully at glowing tablets and laptop screens that show abstract geographic simulations — small maps, charts, weather curves, river deltas. Around the screens, soft glowing data lines and tiny abstract symbols (cloud, leaf, mountain) float gently as if the simulation is escaping the screen into the room. Warm sunlight from a window on the left. Friendly, focused, curiosity-driven mood. Wide horizontal composition with negative space on the right side."
[geografie-didaktik]="$PROMPT_BASE Scene: A geography classroom scene from a slight elevated angle, a teacher standing in front of a large stylised map of Austria and the Alps, gesturing toward mountains and rivers; in the foreground three pupils with open notebooks and a small globe on the desk; the wall behind shows simplified topography with peaks, valleys and a winding river. Wooden desks, tall window with alpine landscape outside (rolling green hills, distant snow-capped peaks under a calm sky). Atmosphere is calm, scholarly, modern Austrian middle-school feel. Wide horizontal composition."
)
TARGETS=("$@")
if [ ${#TARGETS[@]} -eq 0 ]; then TARGETS=(lernen-durch-simulation geografie-didaktik); fi
for id in "${TARGETS[@]}"; do
prompt="${PROMPTS[$id]}"
if [ -z "$prompt" ]; then echo "x $id: kein Prompt definiert"; continue; fi
if [ -f "${id}.png" ] && [ -z "$FORCE" ]; then
echo "ok ${id}.png schon vorhanden (FORCE=1 zum Ueberschreiben)"
continue
fi
echo "-> ${id}: generiere ..."
payload=$(PROMPT="$prompt" python -c 'import json,os; print(json.dumps({"model":"dall-e-3","prompt":os.environ["PROMPT"],"n":1,"size":"1792x1024","quality":"standard"}))')
resp=$(curl -s https://api.openai.com/v1/images/generations \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d "$payload")
url=$(echo "$resp" | python -c 'import sys,json
d=json.load(sys.stdin)
print(d.get("data",[{}])[0].get("url",""))' 2>/dev/null)
if [ -z "$url" ]; then
err=$(echo "$resp" | python -c 'import sys,json
try: print(json.load(sys.stdin).get("error",{}).get("message","?"))
except: print("unparseable")' 2>/dev/null)
echo "x ${id}: Fehler - $err"
continue
fi
curl -s "$url" -o "${id}.png"
echo "ok ${id}.png ($(du -h "${id}.png" | cut -f1))"
sleep 2
done