diff --git a/public/image-modified.webp b/public/image-modified.webp index f5cd698..fa30048 100644 Binary files a/public/image-modified.webp and b/public/image-modified.webp differ diff --git a/public/image.png b/public/image.png new file mode 100644 index 0000000..30f03d2 Binary files /dev/null and b/public/image.png differ diff --git a/routes/web.php b/routes/web.php index f004ca2..dddd38b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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));