PHP code example of studiow / glideformat

1. Go to this page and download the library: Download studiow/glideformat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

studiow / glideformat example snippets


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

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

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']);
});