, (*1)
JETPACK PHOTON WRAPPER
What is Photon?
Photon is an image acceleration and modification service for Jetpack-connected WordPress sites. Converted images are cached automatically and served from the WordPress.com CDN. Images can be cropped, resized, and filtered by using a simple API controlled by GET query arguments. When Photon is enabled in Jetpack, images are updated on the fly., (*2)
Why wrapper?
This wrapper allows you to use photon on your host (servers) and its fully object oriented., (*3)
Installation
$ composer require bencagri/photon
Notice: to use it on your servers, you need to install gmagick package, (*4)
Sample implementation., (*5)
<?php
use Photon\Wrapper\Generate;
use Photon\Wrapper\Effect\Height;
use Photon\Wrapper\Effect\Width;
use Photon\Wrapper\Effects;
require 'vendor/autoload.php';
// Set your effects
$effects = new Effects(
new Width(500),
new Height(500)
);
$imageUrl = 'http://sample-site.com/sample-image.jpg';
//Generate image with your effects
$process = new Generate($imageUrl,$effects);
$process->process();
You can combine multiple effects also., (*6)
<?php
use Photon\Wrapper\Effect\Crop;
use Photon\Wrapper\Effect\Filter;
use Photon\Wrapper\Effects;
$crop = new Crop(500,250,330,300);
$effects = new Effects(
$crop,
new Filter('emboss')
);
Full documentation of all effects., (*7)
Licence
- The Photon Wrapper is open-sourced software licensed under the MIT license.
- The Photon is open-sourced software licenced under GNU GENERaL PUBLIC LICENCE