Flag background for prideavatar.
For transparent avatars, having the desired flag as the background would be better than just a black color.
@TheClonerx can you provide some examples and a bit of clarification?
When an avatar has already an alpha channel, avatar.putalpha(mask), in the crop_avatar method, replaces it, so the original transparent pixels become black.
A solution would be preserving the original transparent pixels by extracting the alpha channel of the image and performing a logical and with the crop mask before applying it to the avatar (it would be necessary to import ImageChops module from PIL).
@staticmethod
def crop_avatar(avatar):
"""This crops the avatar into a circle."""
alpha = avatar.split()[-1].convert("1") # new line
mask = Image.new("1", avatar.size, 0) # mode changed to 1
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + avatar.size, fill=255)
mask = ImageChops.logical_and(mask, alpha) # new line
avatar.putalpha(mask)
return avatar
Current result:
Desired result:

Greetings. Great idea y'all, I think this should be implemented.
(Sorry, 2 years late)