Skip to content

Commit

Permalink
fix(quote): transparent avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Jan 28, 2024
1 parent 645278d commit 6ff117e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libs/quote/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def _paste_avatar(self):
mask_im = Image.new("L", self.avatar.size, 0)
draw = ImageDraw.Draw(mask_im)
draw.ellipse((0, 0, AVATAR_SIZE, AVATAR_SIZE), fill=255)
self.result.paste(self.avatar, AVATAR_POSITION, mask_im)
avatar_with_mask = Image.new('RGBA', self.avatar.size, (0, 0, 0, 0))
avatar_with_mask.paste(self.avatar, mask=mask_im)
self.result.paste(avatar_with_mask, AVATAR_POSITION, avatar_with_mask)

@cached(Cache(maxsize=1_000))
def _find_max_text_size(self, text: str, rect: tuple[tuple[int, int], tuple[int, int]], font_name: str, font_size: str):
Expand Down Expand Up @@ -82,7 +84,6 @@ def _split_text(self, text: str):
line.append(word)
if line:
lines.append(line)
print([len(' '.join(line)) for line in lines])
return '\n'.join(' '.join(line) for line in lines if line)

def _generate_quote_text(self):
Expand Down

0 comments on commit 6ff117e

Please sign in to comment.