ImagizerPHP
The official PHP Client for the Imagizer Media Engine, (*1)
The Imagizer Media Engine accelerates media delivery to your mobile Apps or Webpages by dynamically rescaling, cropping, and compressing images in real time. See all Imagizer features in our Doc., (*2)
Installation
Using Composer
Define the following requirement in your composer.json file, (*3)
{
"require": {
"nventify/imagizer-php": "0.1.*"
}
}
Then include the auto loading path in your application, (*4)
require __DIR__ . '/vendor/autoload.php';
Basic Usage
Using the free to test Imagizer Demo Service, (*5)
// 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
]);
Using your own Imagizer Instance, (*6)
// 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
]);