m1n64/imageresizer-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

m1n64/imageresizer-sdk

最新稳定版本:1.0.2

Composer 安装命令:

composer require m1n64/imageresizer-sdk

包简介

ImageResizer SDK for PHP

README 文档

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)

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-04-30