ingowalther / image-minify-php-client
Image Minify API 的 PHP 实现
0.0.4
2015-11-11 20:04 UTC
Requires
- guzzlehttp/guzzle: 6.1.0
This package is not auto-updated.
Last update: 2024-09-14 17:48:27 UTC
README
Image Minify API 的基础 PHP 实现
查看 https://github.com/ingowalther/image-minify-api
安装
composer require ingowalther/image-minify-php-client
用法
$client = new \IngoWalther\ImageMinifyPhpClient\Client\ImageMinifyApiClient($serverUrl, $apiKey);
获取压缩图像
返回一个 "CompressedImage" 对象
/** @var \IngoWalther\ImageMinifyPhpClient\Response\CompressedImage $compressedImage */ $compressedImage = $client->getCompressedImage($imagePath); // The size before compression $oldSize = $compressedImage->oldSize; // The size after compression $newSize = $compressedImage->newSize; // The saving in percent $saving = $compressedImage->saving; // The binary-content of the compressed image $binaryContent = $compressedImage->binaryContent;
写入压缩图像
压缩指定的图像并将结果写入目标路径
$success = $client->writeCompressedImage($imagePath, $newImagePath);