studiow/glideformat

Use the excellent glide api with named presets

v1.0.0 2016-01-07 15:37 UTC

This package is auto-updated.

Last update: 2024-04-24 20:22:55 UTC


README

Use the excellent glide api with named presets

Some basic examples

$server = Studiow\GlideFormat\GlideFormatServer::createServer([
            "source" =>  '/path/to/uploads',
            "cache" => '/path/to/cache',
        ]);

$server->addPreset("thumbnail", ["w" => 100, "h" => 150, "fit" => "crop"]);

And when using a router, you could something like this:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

// create $server like above

$router = new \League\Route\RouteCollection();

$router->get("/img/{format}/{filename}", function(Request $request, Response $response, array $args) use ($server) {
     $server->outputImage($args['filename'], $args['format']);
});