new CURLFile($imageFile),
‘size’ => ‘auto’,
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode == 200) {
// Сохранение результата
header(‘Content-Type: image/png’);
echo $response;
} else {
// Обработка ошибки
$error = json_decode($response, true);
header(‘Location: index.php?error=’ . urlencode($error[‘message’]));
}
} else {
header(‘Location: index.php’);
}