from PIL import Image, ImageDraw, ImageFont
@client.command()
async def test(ctx):
image = Image.open('background.png')
font = ImageFont.truetype('arial.ttf', size=35)
draw.text((0, 0), f"Example", fill="white", font=font)
draw.save("image.png")
await ctx.send(File=discord.File("image.png"))
如何在不先保存图像的情况下发送使用Pillow.py
创建的图像。我已经试图在Stack Overflow上搜索可用的解决方案,但是没有找到任何可行的方法。感谢任何帮助!之前我尝试使用IO解决此问题,但最终只会发送空文件。
with io.BytesIO() as output:\n image.save(output, format=[...])
, 需要指定格式。 - Mensch