Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2746 - Makeup causing issues aswell #2968

Merged
merged 5 commits into from
Nov 30, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions app/avatar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,28 @@ 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
Expand Down