Web: bug - wallpapers aren't placed correctly in saved image

Created on 9 Nov 2018  路  13Comments  路  Source: gitcoinco/web

see this screencast:

screen recording 2018-11-09 at 10 49 am

acceptance criteria:

  • fix this bug
bug

Most helpful comment

Just tested - after a couple of adaption also I can be a kawaii anime girl
image
And regarding spongebob's starfish face man:
image

diff --git a/app/avatar/utils.py b/app/avatar/utils.py
index 7ef066a7a..f0dcffbdc 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

All 13 comments

@Dgilliams @kuhnchris any interest in this one? if not, ill bounty it

Sure, but, @owocki i noticed this during development: this is very hard depending on the view port set on the new background. Is this one of the new ones?

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__This issue now has a funding of 0.3 ETH (63.27 USD @ $210.89/ETH) attached to it.__

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work has been started__.

These users each claimed they can complete the work by 8聽months from now.
Please review their action plans below:

1) kuhnchris has started work.

Analyzing the viewport / issue with the background

Learn more on the Gitcoin Issue Details page.

@kuhnchris having any luck? or are you still blocked by docker stuff..

yes and yes, I'll try to setup a local docker now if that works...

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work for 0.3 ETH (39.93 USD @ $133.1/ETH) has been submitted by__:

  1. @kuhnchris

@owocki please take a look at the submitted work:

  • PR by @kuhnchris

鈿★笍 A *Always Shipping* Kudos has been sent to @kuhnchris for this issue from @owocki. 鈿★笍 Nice work @kuhnchris! Your Kudos has automatically been sent in the ETH address we have on file.

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__The funding of 0.3 ETH (33.71 USD @ $112.37/ETH) attached to this issue has been approved & issued to @kuhnchris.__

hey @kuhnchris i'm seeing this on the new mask feature that was developed... see https://c.gitcoin.co/avatars/dc4a2fb8fee84af6492f66e068d192d7/owocki.svg

any chance your fix for wallpapers could apply to the mask feature? will happily tip if so

Most likely this should work. It depends on how the mask is sized. If the mask-feature is live I can take a look at the test instance if you want.

Just tested - after a couple of adaption also I can be a kawaii anime girl
image
And regarding spongebob's starfish face man:
image

diff --git a/app/avatar/utils.py b/app/avatar/utils.py
index 7ef066a7a..f0dcffbdc 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

thanks @kuhnchris -- mind submitting a PR with that patch?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kziemianek picture kziemianek  路  3Comments

NukeManDan picture NukeManDan  路  3Comments

pelsasser picture pelsasser  路  4Comments

Skyge picture Skyge  路  3Comments

kuhnchris picture kuhnchris  路  4Comments