From 1832ea431c6e6b0d0e0ddd4413912354650c4e82 Mon Sep 17 00:00:00 2001 From: Lukas Joss Date: Fri, 30 Aug 2024 10:04:02 +0200 Subject: [PATCH] PB-302: Change resize icon logic --- app/helpers/icons.py | 2 +- app/icon.py | 2 +- app/routes.py | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/helpers/icons.py b/app/helpers/icons.py index 40d2844..4d4481c 100644 --- a/app/helpers/icons.py +++ b/app/helpers/icons.py @@ -19,7 +19,7 @@ def get_icon_template_url(base_url='', with_color=True): f"@{{icon_scale}}{color_part}.png" -def calculate_icon_size(size, icon_set, scale=1): +def calculate_icon_size(size, scale=1): """ Calculate icon size so that the size of the smaller dimension is equal to the standard icon size multiplied by the scaling diff --git a/app/icon.py b/app/icon.py index a592482..c548e10 100644 --- a/app/icon.py +++ b/app/icon.py @@ -94,7 +94,7 @@ def get_size(self): A tuple with the size of the specified icon (x,y) """ with Image.open(self.get_icon_filepath()) as img: - return calculate_icon_size(img.size, self.icon_set) + return calculate_icon_size(img.size) def serialize(self): """ diff --git a/app/routes.py b/app/routes.py index 3ab9965..e2bb748 100644 --- a/app/routes.py +++ b/app/routes.py @@ -18,7 +18,6 @@ from app.icon_set import IconSet from app.icon_set import get_all_icon_sets from app.settings import DEFAULT_COLOR -from app.settings import DEFAULT_ICON_SIZE from app.version import APP_VERSION logger = logging.getLogger(__name__) @@ -97,9 +96,8 @@ def colorized_icon( if image.mode == 'P': image = image.convert('RGBA') - new_size = calculate_icon_size(image.size, icon_set, scale) - if min(new_size[0], new_size[1]) != DEFAULT_ICON_SIZE: - image = image.resize((new_size[0], new_size[1])) + new_size = calculate_icon_size(image.size, scale) + image = image.resize((new_size[0], new_size[1])) if icon_set.colorable: image = Image.composite(Image.new("RGB", image.size, (red, green, blue)), image, image) output = BytesIO()