From 6c0825555527b2b22f77d3935aac94be6c987a9a Mon Sep 17 00:00:00 2001 From: Christian Bastian <80225746+cdb-boop@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:56:49 -0400 Subject: [PATCH] Update CSS and JavaScript to match preview ratio (3/2). - Changed thumbnail resampling method to `BOX` when downscaling preview. --- __init__.py | 6 +++++- web/model-manager.css | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index c4aef05..0706783 100644 --- a/__init__.py +++ b/__init__.py @@ -385,7 +385,11 @@ async def get_model_preview(request): crop_box = (0, y0, w0, y0 + int(crop_height_fp)) image = image.crop(crop_box) - image.thumbnail((w, h)) + if w < w0 and h < h0: + resampling_method = Image.Resampling.BOX + else: + resampling_method = Image.Resampling.BICUBIC + image.thumbnail((w, h), resample=resampling_method) if not image_format_is_equal(image_format, response_image_format) and (response_image_format == 'JPEG' or response_image_format == 'JPG'): image = image.convert('RGB') diff --git a/web/model-manager.css b/web/model-manager.css index 420d5d7..f2afa0b 100644 --- a/web/model-manager.css +++ b/web/model-manager.css @@ -322,8 +322,8 @@ /* preview image */ .model-manager .item { position: relative; - width: 230px; - height: 345px; + width: 240px; + height: 360px; text-align: center; overflow: hidden; border-radius: 8px;