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; }