28 lines
669 B
PHP
28 lines
669 B
PHP
<?php
|
|
|
|
namespace Modules\Lpj\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\Lpj\app\Services\ImageResizeService;
|
|
|
|
class ImageController extends Controller
|
|
{
|
|
protected $imageService;
|
|
|
|
public function __construct(ImageResizeService $imageService)
|
|
{
|
|
$this->imageService = $imageService;
|
|
}
|
|
|
|
public function show(Request $request, $path)
|
|
{
|
|
$width = $request->query('w');
|
|
$quality = $request->query('q', 80);
|
|
|
|
$resizedPath = $this->imageService->resize($path, $width, null, $quality);
|
|
|
|
return response()->file(storage_path('app/public/' . $resizedPath));
|
|
}
|
|
}
|