- PHP-based web interface for image upscaling using Topaz Labs API - Multiple image upload with batch processing support - AI model selection (Standard V2, Low Resolution V2, CGI, etc.) - Output resolution options from 2K to 8K - Face enhancement feature - Real-time job tracking and status monitoring - Bulk download functionality - Dark mode toggle - Microsoft authentication integration - Comprehensive README with installation instructions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
No EOL
2.6 KiB
PHP
71 lines
No EOL
2.6 KiB
PHP
<?php
|
|
include 'config.php';
|
|
|
|
if (isset($_GET['process_id'])) {
|
|
$process_id = $_GET['process_id'];
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, "https://api.topazlabs.com/image/v1/download/$process_id");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
'Accept: application/json',
|
|
'X-API-Key: ' . API_TOKEN
|
|
]);
|
|
|
|
$response = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
if ($response === false) {
|
|
echo "cURL Error: " . curl_error($ch);
|
|
} else {
|
|
$data = json_decode($response, true);
|
|
if (isset($data['download_url'])) {
|
|
// Check if the download has expired
|
|
if (isset($data['expiry']) && $data['expiry'] < time()) {
|
|
echo "Error: Download link has expired.";
|
|
} else {
|
|
// Get filename from process ID
|
|
$filename = 'topaz_' . $process_id . '.jpeg';
|
|
|
|
// Download the file directly using curl
|
|
$chDownload = curl_init($data['download_url']);
|
|
|
|
// Set up temp file to store download
|
|
$tempFile = tempnam(sys_get_temp_dir(), 'topaz_');
|
|
$fp = fopen($tempFile, 'wb');
|
|
|
|
curl_setopt($chDownload, CURLOPT_FILE, $fp);
|
|
curl_setopt($chDownload, CURLOPT_FOLLOWLOCATION, true);
|
|
curl_exec($chDownload);
|
|
|
|
$dlError = curl_error($chDownload);
|
|
curl_close($chDownload);
|
|
fclose($fp);
|
|
|
|
if ($dlError) {
|
|
echo "Error downloading file: " . $dlError;
|
|
@unlink($tempFile);
|
|
} else {
|
|
// Output file with forced download headers
|
|
header('Content-Description: File Transfer');
|
|
header('Content-Type: application/octet-stream');
|
|
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
|
header('Expires: 0');
|
|
header('Cache-Control: must-revalidate');
|
|
header('Pragma: public');
|
|
header('Content-Length: ' . filesize($tempFile));
|
|
|
|
readfile($tempFile);
|
|
@unlink($tempFile); // Clean up temp file
|
|
exit;
|
|
}
|
|
}
|
|
} else {
|
|
echo "Error: Download URL not available. Response: " . $response;
|
|
}
|
|
}
|
|
} else {
|
|
echo "Error: No process ID provided";
|
|
}
|
|
?>
|