我似乎想不出如何使用discord.py调整图像和gif的大小。
如果有人能告诉我如何使用discord.py调整图像和gif的大小,我将非常感激,因为它为我的机器人的核心功能提供了动力。
发布于 2020-10-24 01:08:49
不,在discord.py中没有这样的库可以调整图像和gif的大小。尽管你可以从pillow获得帮助:
从谷歌下载图像(以前需要的模板)现在转到命令提示符,输入pip install pillow
from PIL, import Image
from io import BytesIO现在这是我的代码,你可以根据你的requirements来设置它
@client.command()
async def wanted(ctx, user:discord.Member = None):
if user=None:
user=ctx.author
wanted=image.open(wanted.jpg)
asset= ctx.author.avatar_url_as(size=128)
data = BytesIO(await asset.read())
pfp = image.open(data)pfp=pfp.resize(200,200) #you can resize it to any size you want
wanted.paste(pfp, (100, 200)) # this is my graphical reading
wanted.save(profile.jpg)
await ctx.send(file, discord.File('profile.jpg'))这就是了。我给了你方向,如果你仍然面临任何问题,请随时在下面发表评论,我会尝试回复它;)
发布于 2021-06-09 05:08:35
使用类似Pillow的模块(导入PIL)
https://stackoverflow.com/questions/64492624
复制相似问题