|
|
@ -23,7 +23,7 @@ Route::get('/image.{ext}', function (Request $request) { |
|
|
|
// dump($request->);
|
|
|
|
|
|
|
|
if (!isset($request->w) && !isset($request->h)) { |
|
|
|
$image = Image::thumbnail('../public/image.jpg', getimagesize('../public/image.jpg')[0]); |
|
|
|
$image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0]); |
|
|
|
} |
|
|
|
|
|
|
|
if ($request->r) { |
|
|
@ -39,22 +39,26 @@ Route::get('/image.{ext}', function (Request $request) { |
|
|
|
$request->h = $request->h * $rArray[1]; |
|
|
|
$request->w = $request->h * $rArray[0]; |
|
|
|
} |
|
|
|
if (!isset($request->w) && !isset($request->h)) { |
|
|
|
$request->h = getimagesize('../public/image.png')[0] * $rArray[1]; |
|
|
|
$request->w = getimagesize('../public/image.png')[0] * $rArray[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($request->w) && !isset($request->h)) { |
|
|
|
$image = Image::thumbnail('../public/image.jpg', $request->w, ['height' => getimagesize('../public/image.jpg')[1]]); |
|
|
|
$image = Image::thumbnail('../public/image.png', $request->w, ['height' => getimagesize('../public/image.png')[1]]); |
|
|
|
} |
|
|
|
|
|
|
|
if (!isset($request->w) && isset($request->h)) { |
|
|
|
$image = Image::thumbnail('../public/image.jpg', getimagesize('../public/image.jpg')[0], ['height' => $request->h]); |
|
|
|
$image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0], ['height' => $request->h]); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($request->w) && isset($request->h) && !($request->canv == true)) { |
|
|
|
$image = Image::thumbnail('../public/image.jpg', $request->w, ['height' => $request->h, 'crop' => 'centre']); |
|
|
|
$image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h, 'crop' => 'centre']); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($request->w) && isset($request->h) && $request->canv == true) { |
|
|
|
$image = Image::thumbnail('../public/image.jpg', $request->w, ['height' => $request->h]); |
|
|
|
$image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h]); |
|
|
|
$widthH = ($request->h - $image->height) / 2; |
|
|
|
$widthW = ($request->w - $image->width) / 2; |
|
|
|
$image = $image->embed( |
|
|
@ -88,7 +92,7 @@ Route::get('/image.{ext}', function (Request $request) { |
|
|
|
} |
|
|
|
|
|
|
|
$image->writeToFile('image-modified.' . $request->ext, [ |
|
|
|
'Q' => $request->q |
|
|
|
'Q' => isset($request->q) ? $request->q : 100 |
|
|
|
]); |
|
|
|
|
|
|
|
return response()->file(public_path("image-modified." . $request->ext)); |
|
|
|