Skip to content

Commit

Permalink
add Slir
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolethanh committed Nov 30, 2016
1 parent 6e92730 commit d49d210
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 226 deletions.
34 changes: 34 additions & 0 deletions app/Http/Controllers/SlirController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

/*
*
* Parameter Mearning Example
w Maximum width /slir/w100/path/to/image.jpg
h Maximum height /slir/h100/path/to/image.jpg
c Crop ratio /slir/c1x1/path/to/image.jpg
q Quality /slir/q60/path/to/image.jpg
b Background fill color /slir/bf00/path/to/image.png
p Progressive /slir/p1/path/to/image.jpg
g Grayscale /slir/g1/path/to/image.jpg
*/

class SlirController extends Controller
{
//
public function slirAction($size, $user_id, $album_id, $file_path)
{
define('SLIR_CONFIG_CLASSNAME', \App\SLIR\SLIRConfig::class);

$slir = new \SLIR\SLIR();
$slir->processRequestFromURL();

// SLIR handle response by itself
// Do not return anything
}
}
1 change: 1 addition & 0 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@

Route::get('/home', 'HomeController@index');

Route::get('slir/{size}/{user_id}/{album_id}/{image_file}', 'SlirController@slirAction');
28 changes: 28 additions & 0 deletions app/SLIR/SLIRConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* User: ZE
* Date: 2016/12/01
* Time: 1:23
*/

namespace App\SLIR;


class SLIRConfig extends \SLIR\SLIRConfigDefaults
{
public static function init()
{
static::$garbageCollectDivisor = 400;
static::$garbageCollectFileCacheMaxLifetime = 345600;
static::$browserCacheTTL = 604800; // 7*24*60*60
static::$pathToCacheDir = storage_path('SLIR/cache');
static::$pathToErrorLog = storage_path('SLIR/files/slir-error-log');
static::$documentRoot = storage_path('app/photos');
static::$urlToSLIR = '/slir'; // Tell SLIR to listen after "/assets" route
static::$maxMemoryToAllocate = 64;
// This must be the last line of this function
parent::init();
}
}

SLIRConfig::init();
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"predis/predis": "~1.0",
"pusher/pusher-php-server":"~2.0",
"vinkla/pusher": "^2.0",
"endroid/qrcode": "^1.5"
"endroid/qrcode": "^1.5",
"rezozero/slir": "2.1.*"

},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
Loading

0 comments on commit d49d210

Please sign in to comment.