#!/bin/bash
# Generate all 20 farm animal coloring pages
OUTDIR="/home/node/.openclaw/workspace/books/animali-della-fattoria/images"
SCRIPT="/home/node/.openclaw/workspace/skills/aiml-image-video/scripts/gen_image.py"
MODEL="openai/gpt-image-1"

BASE_PROMPT="Black and white line art coloring page for toddlers age 3-5. Thick bold lines (5pt), minimal details, large cute eyes, chunky cartoon style, clean black outlines, white background, no shading, no grayscale, no colors. Simple design."

prompts=(
  "$BASE_PROMPT A cute cow standing in a farm field, simple chunky body, big eyes"
  "$BASE_PROMPT A happy pig standing near a muddy puddle, round chunky body, curly tail"
  "$BASE_PROMPT A fluffy sheep standing on grass, woolly body, simple legs"
  "$BASE_PROMPT A hen pecking on the ground near some grass, round body, simple wings"
  "$BASE_PROMPT A friendly horse standing in a pasture with a simple fence behind, long mane"
  "$BASE_PROMPT A cute rabbit sitting up with big ears, simple round body, tiny nose"
  "$BASE_PROMPT A duck swimming on a small pond with simple wavy water lines"
  "$BASE_PROMPT A goat standing on a little hill with small horns, simple friendly face"
  "$BASE_PROMPT A donkey standing in a field with long ears, gentle eyes, simple body"
  "$BASE_PROMPT A rooster standing proudly with a simple comb on head, tail feathers"
  "$BASE_PROMPT Two cute chicks standing next to each other, tiny round bodies, simple beaks"
  "$BASE_PROMPT A friendly farm dog sitting on grass, floppy ears, wagging tail"
  "$BASE_PROMPT A farm cat sitting with a curled tail, round face, pointed ears"
  "$BASE_PROMPT A turkey with a simple fan tail, round body, wattle under beak"
  "$BASE_PROMPT A cow eating grass with head down, simple body, spots on body"
  "$BASE_PROMPT A pig rolling in mud, happy expression, simple round shape"
  "$BASE_PROMPT A sheep with a baby lamb next to it, both fluffy, simple faces"
  "$BASE_PROMPT A hen with three tiny chicks following her, all simple round shapes"
  "$BASE_PROMPT A horse running with legs stretched, simple motion, flowing mane"
  "$BASE_PROMPT A simple farm scene: barn in background, sun, cow and sheep in front, all very simple chunky style"
)

mkdir -p "$OUTDIR"

for i in "${!prompts[@]}"; do
  n=$((i + 1))
  padded=$(printf "%02d" $n)
  echo "=== Generating page $padded/20 ==="
  python3 "$SCRIPT" \
    --prompt "${prompts[$i]}" \
    --model "$MODEL" \
    --out-dir "$OUTDIR" \
    --size "1024x1024" \
    --output-format "png" \
    --verbose 2>&1 | tail -5
  
  # Rename to predictable name
  latest=$(ls -t "$OUTDIR"/image-*.png 2>/dev/null | head -1)
  if [ -n "$latest" ]; then
    mv "$latest" "$OUTDIR/page-${padded}.png"
    echo "✅ Page $padded saved"
  else
    echo "❌ Page $padded failed"
  fi
  
  # Small delay between requests
  sleep 2
done

echo ""
echo "=== All done! ==="
ls -la "$OUTDIR"/page-*.png 2>/dev/null | wc -l
echo "images generated"
