R
R
Ravenswood2021-07-12 20:29:43
Python
Ravenswood, 2021-07-12 20:29:43

How to remove the black background on the profile picture in the pillow library?

Here is my code for getting the user's avatar. But if the user has a transparent background on the avatar, then it will turn black. How to fix it so that there is no black background?

member = ctx.author

banner = Image.open("./core/image/Fon.jpg")

asset = member.avatar_url_as(size = 128)
data = io.BytesIO(await asset.read())
pfp = Image.open(data)
pfp = pfp.resize((200,200))
banner.paste(pfp, (20,20))
banner.save("profile.png")
await ctx.send(file = discord.File("profile.png"))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-07-12
@Ravenswood

We need to add an alpha channel.
For example: Create transparent png image with Python, Pillow (...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question