HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/panomity.de/vr.panomity.com/api/regenerate-all-depthmaps.php
<?php
/**
 * Regeneriert alle existierenden Depthmaps mit neuen Einstellungen:
 * - Encoder: vitl (statt vitb)
 * - Input-Size: 1024 (statt 518)
 * - Grayscale: false (statt true)
 * 
 * Usage: php regenerate-all-depthmaps.php
 */

$dbPath = __DIR__ . '/../admin/data/vrm.db';
if (!file_exists($dbPath)) {
    die("ERROR: Database not found at: $dbPath\n");
}

$db = new SQLite3($dbPath);
$db->busyTimeout(5000);

// Hole alle Panos mit aktivierten Depthmaps
$result = $db->query("SELECT id FROM panos WHERE depthmap_visible = 1 ORDER BY id");
if (!$result) {
    die("ERROR: Could not query database\n");
}

$panos = [];
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
    $panos[] = $row['id'];
}

$total = count($panos);
if ($total === 0) {
    echo "Keine Panos mit aktivierten Depthmaps gefunden.\n";
    exit(0);
}

echo "Gefunden: $total Panos mit aktivierten Depthmaps\n";
echo "Starte Regenerierung mit Einstellungen:\n";
echo "  - Encoder: vitl\n";
echo "  - Input-Size: automatisch (basierend auf Bildgröße, max. 4096)\n";
echo "  - Grayscale: false\n\n";

$success = 0;
$failed = 0;
$skipped = 0;

// Basis-URL für API-Aufrufe
if (php_sapi_name() === 'cli') {
    // CLI-Modus: Versuche die richtige URL zu ermitteln
    // Prüfe ob wir auf vr.panomity.com sind
    $apiUrl = 'http://vr.panomity.com/api/depth-generate.php';
    echo "HINWEIS: CLI-Modus erkannt. Verwende: $apiUrl\n\n";
} else {
    $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'] ?? 'localhost';
    $apiUrl = $scheme . '://' . $host . '/api/depth-generate.php';
}

foreach ($panos as $index => $panoId) {
    $current = $index + 1;
    echo "[$current/$total] Regeneriere Depthmap für Pano ID: $panoId ... ";
    
    // Prüfe ob Depthmap-Datei existiert
    $dmapFile = __DIR__ . '/../panos/p' . $panoId . '.tiles/dmap.png';
    if (!file_exists($dmapFile)) {
        $dmapFile = __DIR__ . '/../panos/p' . $panoId . '.tiles/dmap.jpg';
    }
    
    if (!file_exists($dmapFile)) {
        echo "SKIPPED (keine Depthmap-Datei gefunden)\n";
        $skipped++;
        continue;
    }
    
    // API-Aufruf vorbereiten
    $payload = [
        'pano_id' => $panoId,
        'encoder' => 'vitl',
        'grayscale' => 0
        // input_size wird automatisch von der API basierend auf der Bildgröße ermittelt
    ];
    
    // API-Aufruf via HTTP
    $ch = curl_init($apiUrl);
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => json_encode($payload),
        CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 900, // 15 Minuten für große Bilder mit vitl
        CURLOPT_CONNECTTIMEOUT => 30,
    ]);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    
    if ($httpCode === 200 && empty($error)) {
        $result = json_decode($response, true);
        if (isset($result['success']) && $result['success']) {
            echo "OK\n";
            $success++;
        } else {
            echo "FAILED (" . ($result['error'] ?? 'Unknown error') . ")\n";
            $failed++;
        }
    } else {
        echo "FAILED (HTTP $httpCode" . ($error ? ", $error" : "") . ")\n";
        if ($response) {
            $errorData = json_decode($response, true);
            if (isset($errorData['error'])) {
                echo "  Details: " . $errorData['error'] . "\n";
            }
        }
        $failed++;
    }
    
    // Kurze Pause zwischen Requests, um Server nicht zu überlasten
    if ($current < $total) {
        sleep(2);
    }
}

$db->close();

echo "\n=== Zusammenfassung ===\n";
echo "Erfolgreich: $success\n";
echo "Fehlgeschlagen: $failed\n";
echo "Übersprungen: $skipped\n";
echo "Gesamt: $total\n";

?>