From cd71b194e6787148d0f0e873f18d6fd925ea7c3b Mon Sep 17 00:00:00 2001 From: Wisp X Date: Wed, 19 Jan 2022 15:05:44 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=94=B9=E8=BF=9B=E7=BC=A9?= =?UTF-8?q?=E7=95=A5=E5=9B=BE=E7=94=9F=E6=88=90=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/User/ImageController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/User/ImageController.php b/app/Http/Controllers/User/ImageController.php index 6e1471cc..0b42f467 100644 --- a/app/Http/Controllers/User/ImageController.php +++ b/app/Http/Controllers/User/ImageController.php @@ -149,12 +149,13 @@ class ImageController extends Controller $stream = $image->filesystem()->readStream($image->pathname); $img = \Intervention\Image\Facades\Image::make($stream); - $w = $image->width; - $h = $image->height; - $width = $height = 400; + $width = $w = $image->width; + $height = $h = $image->height; - if ($w > $width && $h > $height) { - $scale = min($width / $w, $height / $h); + $max = 400; // 最大宽高 + + if ($w > $max && $h > $max) { + $scale = min($max / $w, $max / $h); $width = (int)($w * $scale); $height = (int)($h * $scale); }