From c690da514e3b44a60dba5712e32ff75e169afe07 Mon Sep 17 00:00:00 2001 From: KuhnChris Date: Wed, 28 Nov 2018 00:23:32 +0100 Subject: [PATCH 1/2] Fix #2746 - Makeup causing issues aswell --- app/avatar/utils.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/avatar/utils.py b/app/avatar/utils.py index 7ef066a7a42..f0dcffbdc5c 100644 --- a/app/avatar/utils.py +++ b/app/avatar/utils.py @@ -246,22 +246,29 @@ def build_avatar_component(path, icon_size=None, avatar_size=None): scale_factor = icon_size[1] / avatar_component_size[1] x_to_center = (icon_size[0] / 2) - ((avatar_component_size[0] * scale_factor) / 2) svg = SVG(f'{COMPONENT_BASE}{path}') - if path.startswith('Wallpaper'): + if path.startswith('Wallpaper') or path.startswith('Makeup'): src = transform.fromfile(f'{COMPONENT_BASE}{path}') - + # TODO: Consider width aswell... - # if src.width != None: - # src_width = float(re.sub('[^0-9]','', src.width)) - # else: - # src_width = 900 + if src.width is not None: + src_width = float(re.sub('[^0-9]','', src.width)) + else: + src_width = 900 if src.height is not None: src_height = float(re.sub('[^0-9]', '', src.height)) else: src_height = 1415 scale_factor = icon_size[1] / src_height + if path.startswith('Makeup'): + scale_factor = scale_factor / 2 + svg = svg.scale(scale_factor) - if not path.startswith('Wallpaper'): + if path.startswith('Makeup'): + x_to_center = (icon_size[0] / 2) - ((src_width * scale_factor) / 2) + svg = svg.move(x_to_center, src_height * scale_factor / 2) + + if not path.startswith('Wallpaper') and not path.startswith('Makeup'): svg = svg.scale(scale_factor) svg = svg.move(x_to_center, 0) return svg From 3f93eebf28c95aa2dead20a6655f863956f6b3ce Mon Sep 17 00:00:00 2001 From: KuhnChris Date: Wed, 28 Nov 2018 17:17:07 +0100 Subject: [PATCH 2/2] Update utils.py --- app/avatar/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/avatar/utils.py b/app/avatar/utils.py index f0dcffbdc5c..50f0d0724bf 100644 --- a/app/avatar/utils.py +++ b/app/avatar/utils.py @@ -248,10 +248,9 @@ def build_avatar_component(path, icon_size=None, avatar_size=None): svg = SVG(f'{COMPONENT_BASE}{path}') if path.startswith('Wallpaper') or path.startswith('Makeup'): src = transform.fromfile(f'{COMPONENT_BASE}{path}') - - # TODO: Consider width aswell... + if src.width is not None: - src_width = float(re.sub('[^0-9]','', src.width)) + src_width = float(re.sub('[^0-9]', '', src.width)) else: src_width = 900 @@ -262,12 +261,12 @@ def build_avatar_component(path, icon_size=None, avatar_size=None): scale_factor = icon_size[1] / src_height if path.startswith('Makeup'): scale_factor = scale_factor / 2 - + svg = svg.scale(scale_factor) if path.startswith('Makeup'): x_to_center = (icon_size[0] / 2) - ((src_width * scale_factor) / 2) svg = svg.move(x_to_center, src_height * scale_factor / 2) - + if not path.startswith('Wallpaper') and not path.startswith('Makeup'): svg = svg.scale(scale_factor) svg = svg.move(x_to_center, 0)