'Half transparent image Pillow

How do i make an image half transparent like the dank memer command. Ive been using the putalpha since i found it on the Internet when i was searching for a solution but it didnt work. I am using Pillow.

The code:

class Image_Manipulation(commands.Cog, name="Image Manipulation"):
    def __init__(self, bot:commands.Bot):
        self.bot = bot

    @commands.command(aliases=["Clown","CLOWN"])
    async def clown(self, ctx, user: nextcord.Member = None):
        if user == None:
            user = ctx.author
        
        clown = Image.open(os.path.join("Modules", "Images", "clown.jpg"))

        useravatar = user.display_avatar.with_size(128)
        avatar_data = BytesIO(await useravatar.read())
        pfp = Image.open(avatar_data)
        pfp = pfp.resize((192,192))
        pfp.putalpha(300)
        if pfp.mode != "RGBA":
            pfp = pfp.convert("RGBA")

        clown.paste(pfp, (0,0))
        clown.save("clown_done.png")

        await ctx.send(file = nextcord.File("clown_done.png"))
        
def setup(bot: commands.Bot):
    bot.add_cog(Image_Manipulation(bot))

The dank memer command example: https://imgur.com/a/ZDNyKsG



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source