1e51ef7def
- 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>
81 lines
3.1 KiB
PHP
81 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Atlas-Tool: Bild generieren mit DALL-E 3.
|
|
*
|
|
* NUR LOKAL ausführen. API-Key liegt in v2-platform/.env.local.
|
|
*
|
|
* Aufruf:
|
|
* php image.php --prompt "Scene description" --output path/to/file.png [--resolution 1792x1024] [--quality standard]
|
|
*
|
|
* Der Plattform-Bildstil-Prompt wird automatisch vorangestellt.
|
|
*
|
|
* Status: Skelett — echte OpenAI-Call-Implementierung folgt bei erster
|
|
* Verwendung. Aktuell loggt nur was generiert würde + warnt wenn Key fehlt.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/../../php/config.php';
|
|
|
|
// === Args parsen ===
|
|
$opts = getopt('', ['prompt:', 'output:', 'resolution::', 'quality::', 'dry-run']);
|
|
if (empty($opts['prompt']) || empty($opts['output'])) {
|
|
fwrite(STDERR, "Usage: php image.php --prompt \"...\" --output path.png [--resolution 1792x1024] [--quality standard|hd] [--dry-run]\n");
|
|
exit(1);
|
|
}
|
|
|
|
$prompt = $opts['prompt'];
|
|
$output = $opts['output'];
|
|
$resolution = $opts['resolution'] ?? '1792x1024';
|
|
$quality = $opts['quality'] ?? 'standard';
|
|
$dryRun = isset($opts['dry-run']);
|
|
|
|
// === Bildstil-Prompt voranstellen (Plattform-Standard) ===
|
|
$stylePrompt = "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. — Scene: ";
|
|
$fullPrompt = $stylePrompt . $prompt;
|
|
|
|
echo "[asset-gen/image] Prompt: $fullPrompt\n";
|
|
echo "[asset-gen/image] Auflösung: $resolution\n";
|
|
echo "[asset-gen/image] Quality: $quality\n";
|
|
echo "[asset-gen/image] Output: $output\n";
|
|
|
|
// === API-Key prüfen ===
|
|
if (empty(V2_OPENAI_KEY)) {
|
|
fwrite(STDERR, "[asset-gen/image] FEHLER: OPENAI_API_KEY nicht gesetzt in v2-platform/.env.local\n");
|
|
exit(2);
|
|
}
|
|
|
|
if ($dryRun) {
|
|
echo "[asset-gen/image] --dry-run gesetzt, würde Bild generieren.\n";
|
|
exit(0);
|
|
}
|
|
|
|
// === TODO: echter API-Call ===
|
|
// $ch = curl_init('https://api.openai.com/v1/images/generations');
|
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
// curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
// 'Authorization: Bearer ' . V2_OPENAI_KEY,
|
|
// 'Content-Type: application/json',
|
|
// ]);
|
|
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
|
|
// 'model' => 'dall-e-3',
|
|
// 'prompt' => $fullPrompt,
|
|
// 'n' => 1,
|
|
// 'size' => $resolution,
|
|
// 'quality' => $quality,
|
|
// 'response_format' => 'b64_json',
|
|
// ]));
|
|
// $result = json_decode(curl_exec($ch), true);
|
|
// curl_close($ch);
|
|
// if (isset($result['data'][0]['b64_json'])) {
|
|
// @mkdir(dirname($output), 0775, true);
|
|
// file_put_contents($output, base64_decode($result['data'][0]['b64_json']));
|
|
// echo "[asset-gen/image] OK: gespeichert nach $output\n";
|
|
// exit(0);
|
|
// }
|
|
// fwrite(STDERR, "[asset-gen/image] FEHLER: " . json_encode($result) . "\n");
|
|
// exit(3);
|
|
|
|
fwrite(STDERR, "[asset-gen/image] HINWEIS: Echter API-Call noch nicht implementiert. Stub liefert nichts.\n");
|
|
fwrite(STDERR, " Implementierung folgt bei erstem echten Asset-Bedarf.\n");
|
|
exit(0);
|