PHP SDK
pixozip/sdk — PHP 8.1+, single file, ext-curl only.
Install
composer require pixozip/sdkor drop src/Pixozip.php into your project:
require __DIR__ . '/Pixozip.php';Usage
use Pixozip\Pixozip;
use Pixozip\PixozipException;
$client = new Pixozip([
'apiKey' => getenv('PIXOZIP_API_KEY'),
// 'baseUrl' => 'https://api.pixozip.pretzl.dev', // default
// 'maxRetries' => 3,
// 'retryBaseDelayMs' => 500,
// 'defaultTimeoutMs' => 60000,
]);
try {
$res = $client->shrink(file_get_contents('photo.jpg'), [
'contentType' => 'image/jpeg',
'qualityTier' => 'balanced',
'output' => 'webp',
'quality' => 80,
]);
file_put_contents('photo.opt.webp', $client->download($res['downloadUrl']));
} catch (PixozipException $e) {
error_log("pixozip {$e->status}: " . json_encode($e->body));
}Methods
shrink(string $body, array $opts): array— same response shape as the HTTPPOST /v1/shrink.getJob(string $jobId): array— poll an async job.download(string $url): string— fetch a presigned URL into memory.
Retries on 429 + 5xx, throws PixozipException on 4xx.