- Add Prompt Studio React app with cinematic prompt optimization - Integrate image generation via PHP backend API - Support multi-reference image uploads (up to 14 images) - Add resolution selector (1K/2K/4K) - Make generated prompts editable before image generation - Fix application lighting styles being passed to Gemini API - Reorganize UI: inputs on left, outputs on right - Update api.php to handle multiple reference images - Add get_current_image.php endpoint for session image retrieval 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Get Current Image API
|
|
* Returns the current session image as JSON with base64 data
|
|
*/
|
|
|
|
// Suppress HTML error output
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', 0);
|
|
ini_set('log_errors', 1);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
// Initialize session manager
|
|
require_once 'session_manager.php';
|
|
$sessionManager = new SessionManager();
|
|
|
|
// Initialize auth status with default (for logging)
|
|
$authStatus = [
|
|
'authenticated' => true,
|
|
'user' => [
|
|
'name' => 'User',
|
|
'preferred_username' => 'anonymous@nano-banana-pro.com'
|
|
]
|
|
];
|
|
|
|
// Check authentication (with graceful fallback)
|
|
try {
|
|
if (file_exists(__DIR__ . '/AuthMiddleware.php')) {
|
|
require_once 'AuthMiddleware.php';
|
|
$auth = new AuthMiddleware();
|
|
$authStatus = $auth->isAuthenticated();
|
|
|
|
if (!$authStatus['authenticated']) {
|
|
http_response_code(401);
|
|
echo json_encode([
|
|
'success' => false,
|
|
'error' => 'Authentication required'
|
|
]);
|
|
exit;
|
|
}
|
|
}
|
|
} catch (Exception $e) {
|
|
// Log error but continue without auth (for testing)
|
|
error_log("Auth check failed in get_current_image.php: " . $e->getMessage());
|
|
}
|
|
|
|
try {
|
|
// Get current image from session
|
|
$currentImage = $sessionManager->getCurrentImage();
|
|
|
|
if ($currentImage) {
|
|
echo json_encode([
|
|
'success' => true,
|
|
'data' => $currentImage['data'],
|
|
'mime_type' => $currentImage['mime_type']
|
|
]);
|
|
} else {
|
|
echo json_encode([
|
|
'success' => false,
|
|
'error' => 'No image in current session'
|
|
]);
|
|
}
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'success' => false,
|
|
'error' => $e->getMessage()
|
|
]);
|
|
}
|