await bot.say(message.channel, text, attachment = bot.parse_attachment(data, parsed['filename'] + '.png'))
def create_avatar(self, url, bgfile, fgfile):
- # Get Delta images.
+ # Get bling images.
bg = Image.open(bgfile)
fg = Image.open(fgfile)
if not bg or not fg:
top = math.floor((padded.height - image.height) / 2)
padded.paste(image, (left, top, left + image.width, top + image.height))
+ # Ensure the user's image doesn't extend outside the foreground.
+ try:
+ r, g, b, a = bg.split()
+ if a is not None:
+ padded.putalpha(a)
+ except ValueError:
+ pass
+
# Merge them.
result = Image.alpha_composite(Image.alpha_composite(bg, padded), fg)
b = io.BytesIO()