v0.2.1
0.2.1.0PHP Image Filter library
The Requires
v0.2
0.2.0.0PHP Image Filter library
The Requires
PHP Image Filter library
PHP Library to process images through any number of filter effects, based on a single source image. Web API Inspired by https://github.com/imsky/holder, (*1)
Makes use of the Intervention Image library for image processing., (*2)
``` html, (*3)
, (*4)
The first portion of the path is the image builder path prepend `/image-builder/` which denotes the remaining portion of the path is to be handled by the parser. Next is the path to the image `/path/to/my/file.png`. These should typically be a transparent images to allow certain filters to operate appropriately. And finally there are 2 filters being applied to this image. A special resizing filter `/225x225/` which denotes a 225 pixel width and 225 pixel height, respectively. Followed by `/overlay:2/` an overlay filter, specifying 2 duplicates of the original image to be positioned next to each other. If we had used an original image of ...  ... after utilizing ImagiFly's filter path, the resulting image would be  Setup ----- Check out our [demo](https://github.com/stratease/ImagiFly/tree/master/demo) to see an example setup. It's important to note that on the backend we have a server directive to route to our PHP image builder file based on the `/image-builder/...` path. This will provide a level of overhead for each requested image, and is not recommended for very high traffic sites. We do provide a level of caching to avoid redundant image processing. Our .htaccess for apache ``` apache RewriteEngine On RewriteRule ^image-builder/.*$ image-builder.php [NC,L]
This redirects to our backend script that handles the route parsing and image manipulation., (*5)
``` php, (*6)
use stratease\ImagiFly\Builder; use stratease\ImagiFly\RequestParser; require_once("../vendor/autoload.php"); require_once("PinkFilter.php");, (*7)
$builder = new Builder(['baseDirectory' => DIR.'/images/', // Path where we store base images. Can be in web directory or any location 'cache' => false, // Lets disable the cache so we can see our PinkFilter adjustments per request. // Our request parser. You can provide your own by implementing the RequestParserInterface 'requestParser' => new RequestParser(['requestPath' => $_SERVER['REQUEST_URI'], 'pathPrepend' => 'image-builder'])]);, (*8)
// this is how we register a custom filter, in our case an awesome PinkFilter $builder->addFilterExtension(PinkFilter::getFilterMask(), new PinkFilter());, (*9)
$builder->output(); // This will compile and output the image., (*10)
// Try this path.. /image-builder/chipmunks-are-awesome.png/225x225/overlay:2/pink:unicorn/ // it'll blow your mind!, (*11)
```, (*12)
This implementation also has an example of how to setup a custom filter. Refer to the FilterInterface for further documentation., (*13)
PHP Image Filter library
PHP Image Filter library