nventify / imagizer-php
Imagizer媒体引擎的官方PHP客户端
v0.1.0
2016-09-20 21:48 UTC
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: 5.5
This package is not auto-updated.
Last update: 2024-09-18 19:35:52 UTC
README
Imagizer媒体引擎的官方PHP客户端
Imagizer媒体引擎通过动态调整大小、裁剪和压缩图片,实时加速媒体内容在移动应用或网页上的传输。查看我们文档中的所有Imagizer功能。
安装
使用Composer
在您的composer.json文件中定义以下需求
{
"require": {
"nventify/imagizer-php": "0.1.*"
}
}
然后在您的应用程序中包含自动加载路径
require __DIR__ . '/vendor/autoload.php';
基本用法
使用免费的Imagizer演示服务进行测试
// Initialize the Imagizer Client $imagizerClient = new Imagizer\Client(); // Since we are using Imagizer Engine Demo Service // we'll need to specify our Image storage origin // Imagizer will fetch your images from this endpoint $imagizerClient->setOriginImageHost("example.com"); // Build a URL with resize and cropping params // http://example.com/image.jpg?width=400&height=400&crop=fit&dpr=2&hostname=example.com $imageUrl1 = $imagizerClient->buildUrl("image.jpg", [ "width" => 400, "height" => 500, "crop" => "fit" ]); // Build url with compression // http://example.com/image.jpg?quality=55&hostname=example.com $imageUrl2 = $imagizerClient->buildUrl("image.jpg", [ "quality" => 55 ]);
使用您自己的Imagizer实例
// Initialize the Imagizer Client $imagizerClient = new Imagizer\Client("your-imagizer-instance.example.com"); // Build a URL with resize and cropping params // http://your-imagizer-instance.example.com/image.jpg?width=400&height=400&crop=fit&dpr=2 $imageUrl1 = $imagizerClient->buildUrl("image.jpg", [ "width" => 400, "height" => 500, "crop" => "fit" ]); // Build url with compression // http://your-imagizer-instance.example.com/image.jpg?quality=55 $imageUrl2 = $imagizerClient->buildUrl("image.jpg", [ "quality" => 55 ]);