Files
boc/generate-academy-images.sh
T

69 lines
3.4 KiB
Bash
Raw Normal View History

#!/bin/bash
# Generera Academy-bilder med OpenAI DALL-E (backup när Gemini inte fungerar)
OPENAI_KEY="${OPENAI_API_KEY}"
if [ -z "$OPENAI_KEY" ]; then
echo "❌ OPENAI_API_KEY inte satt"
echo " Sätt med: export OPENAI_API_KEY='sk-...'"
exit 1
fi
echo "🎨 Genererar Academy-bilder med DALL-E..."
# Bilder att generera
declare -A IMAGES=(
["m1l1"]="A friendly illustration of a person with a smartphone photographing a bridge at sunset. Modern, clean style with blue and green colors. Pedagogical feel, not photorealistic. 16:9 format."
["m2l1"]="A technical illustration showing AI analysis of a photograph. Split image: left side shows original bridge photo, right side shows AI analysis overlay marking sharpness, light, composition with color-coded indicators. Futuristic but pedagogical style."
["m2l2"]="Three photos in a row showing the same bridge: 1. Underexposed (too dark), 2. Perfectly exposed (golden hour), 3. Overexposed (too bright). Photorealistic style."
["m2l3"]="Two photos showing a road sign: left is blurry and out of focus, right is razor sharp with magnifying glass effect showing details. Photorealistic with graphic elements."
["m2l4"]="A bridge photographed with correct composition. Overlay showing rule of thirds grid, arrow pointing to main subject, green marking for good composition. Educational diagram style."
["m3l1"]="A map of a city from above with a smartphone in the center. 4 GPS satellites above sending signals to the phone. Color-coded accuracy circles: green (accurate), yellow (medium), red (low)."
["m4l1"]="A person with reflective vest and smartphone photographing a bridge from a safe distance. Traffic cone, safety vest, safety distance marked. Modern, friendly illustration."
["m5l1"]="A stylized map with photo points (A, B, C, D, E) connected by an optimized green route. A person with smartphone following the route efficiently."
["m6l1"]="A horizontal flow diagram showing: 1. Approved photo → 2. AI review → 3. Approval → 4. Payment → 5. Money in account. Modern, clean illustration with icons."
)
mkdir -p academy-images
for key in "${!IMAGES[@]}"; do
echo ""
echo "🖼️ Genererar: $key"
# Generera bild med DALL-E
response=$(curl -s https://api.openai.com/v1/images/generations \
-H "Authorization: Bearer $OPENAI_KEY" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"dall-e-3\",
\"prompt\": \"${IMAGES[$key]}\",
\"size\": \"1792x1024\",
\"quality\": \"standard\",
\"n\": 1
}")
# Extrahera URL
url=$(echo "$response" | python3 -c "import sys,json; print(json.load(sys.stdin)['data'][0]['url'])" 2>/dev/null)
if [ ! -z "$url" ]; then
echo " ✅ Bild genererad"
echo " 📥 Laddar ner..."
# Ladda ner bilden
curl -sL "$url" -o "academy-images/$key.png"
# Ladda upp till S3
aws s3 cp "academy-images/$key.png" \
"s3://quixzoom-landing-prod/academy/images/$key.png" \
--acl public-read \
--content-type "image/png" 2>&1 | grep -q "upload" && echo " ✅ Uppladdad till S3"
else
echo " ❌ Kunde inte generera"
echo " Svar: $response"
fi
done
echo ""
echo "✅ Klart! Bilder sparade i academy-images/"
echo "🔗 URL: https://quixzoom.com/academy/images/"