I made a command that adds text to an image. But the problem is that sometimes the text just goes offscreen if someone inputs a long message. How can I fix this?
@bot.command()
async def Picture1(ctx,*,message=None):
member = ctx.author
if message ==None:
await ctx.send("You have to put a message in idiot")
return
text1 = str(member)
print(text1)
# get an image
base = Image.open(r"C:\Users\User\Pictures\Picture.png").convert("RGBA")
# make a blank image for the text, initialized to transparent text color
txt = Image.new("RGBA", base.size, (255, 255, 255, 0))
# get a font
fnt = ImageFont.truetype(
r"C:\Users\User\fonts\courbi.ttf", 40)
# get a drawing context
d = ImageDraw.Draw(txt)
# draw text, half opacity
d.text((21, 70), "'" + message + "'", font=fnt,
fill=(255, 255, 255, 128))
# draw text, full opacity
d.text((10, 213), "-" + text1, font=fnt, fill=(255, 255, 255, 255))
out = Image.alpha_composite(base, txt)
out.save("picutre1.png", format="png")
print(out.save)
await ctx.send(file=discord.File("quote.png"))