m1n64 / imageresizer-sdk
There is no license information available for the latest version (1.0.2) of this package.
ImageResizer SDK for PHP
1.0.2
2025-05-01 11:19 UTC
Requires
- php: >=8.1
- ext-fileinfo: *
- guzzlehttp/guzzle: ^7.9
- ramsey/uuid: ^4.7
Requires (Dev)
- guzzlehttp/psr7: ^2.7
- phpunit/phpunit: ^12.1
README
This is a lightweight PHP SDK for interacting with the Image Resizer Service. It provides a simple, typed API for uploading and retrieving images via the REST interface.
✨ Features
- Upload images via file, binary, or blob
- Retrieve image metadata and links
- Strict types using DTOs and Enums
- Guzzle-based HTTP client
- Supports optional API key authentication
- Fully unit-tested
If you're looking for Laravel ImageResizer SDK - you may to user this https://github.com/junior-idiot/laravel-imageresizer-sdk
⚙️ Installation
composer require m1n64/imageresizer-sdk
🚀 Quick Start
use M1n64\ImageResizer\Client; $client = new Client( xApiKey: null, // or 'your-api-key', if required baseUrl: 'http://localhost:5689', publicBaseUrl: 'http://localhost:5689', // optional, default is same as `baseUrl`. Used as image URL host ); $image = $client->upload('/path/to/image.jpg'); echo $image->status->value; // 'pending', 'ready', etc.
🔧 Available Methods
✅ Health Check
$ping = $client->ping(); echo $ping->message; // "pong" echo $ping->timestamp->format(DATE_ATOM);
📎 Upload via multipart
$image = $client->upload('/path/to/image.jpg');
🔢 Upload via binary stream
$image = $client->uploadBinary('/path/to/image.jpg');
📁 Upload from blob in memory
$imageData = file_get_contents('/path/to/image.jpg'); $image = $client->uploadFromBlob($imageData, 'my.jpg');
🔍 Get image by ID
$image = $client->get('uuid-here'); echo $image->originalUrl; echo $image->status->isReady() ? 'Ready' : 'Processing';
📊 Response Entity: Image
Image { UuidInterface $id string $originalUrl ?string $compressedUrl int $size string $mime ImageStatus $status ?Thumbnail[] $thumbnails }
Enum ImageStatus
: pending
, processing
, ready
, error
You can call:
$image->status->isReady(); $image->status->isPending();
📖 Related
This SDK is made to work with the Image Resizer Shared Service, which provides:
- A local HTTP/gRPC server
- Image compression to WebP
- Thumbnail generation
- Configurable via JSON or ENV
- Distributed as a standalone binary or Docker image
🎓 Tests
composer test
Tests use full mocking of the HTTP layer (Guzzle), no external service required.
🧙♂️ Author
Made with ❤️ by the Kirill Sakharov (LinkedIn)