From 267a01effcb077cfcab943487593aafdf332e6da Mon Sep 17 00:00:00 2001 From: Kakune55 Date: Thu, 9 May 2024 11:58:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E8=BF=87=E7=A8=8B=E4=B8=AD=E5=9B=BE=E7=89=87=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- file.py | 6 +++--- requirements.txt | 3 ++- templates/view.html | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/file.py b/file.py index e478490..ea1f218 100644 --- a/file.py +++ b/file.py @@ -71,10 +71,10 @@ def thumbnail(input, minSize: int = 600): img = cv2.imdecode(np.frombuffer(input, np.uint8), cv2.IMREAD_COLOR) height = img.shape[0] # 图片高度 width = img.shape[1] # 图片宽度 - if height < width: - newshape = (int(minSize / width * height), minSize) - else: + if height > width: newshape = (minSize, int(minSize / width * height)) + else: + newshape = (int(minSize / height * width), minSize) img = cv2.resize(img, newshape) success, encoded_image = cv2.imencode(".webp", img, [cv2.IMWRITE_WEBP_QUALITY, 75]) return encoded_image.tobytes() diff --git a/requirements.txt b/requirements.txt index b7a17c1..fc6c551 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ shortuuid flask -opencv-python \ No newline at end of file +opencv-python +opencv-python-headless \ No newline at end of file diff --git a/templates/view.html b/templates/view.html index 7b0a733..bcd79c1 100644 --- a/templates/view.html +++ b/templates/view.html @@ -28,7 +28,7 @@ img { display: block; width: 100%; - min-height: 300px; + min-height: 200px; margin-top: 10px; }