generators.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Tuxedo 作者: ClarityMoe 项目源码 文件源码
def magik(self, ctx, target, *args):
        """ Add some magik to your boring-ass images """
        try:
            member = await commands.MemberConverter().convert(ctx, target)
            url = member.avatar_url
        except:
            url = target

        url = url.replace("gif", "png").strip("<>")

        if args:
            opt = args[0]
        else:
            opt = 0.5
        multi = parsers.as_number(opt, 0.5)
        if multi > 10:
            return await ctx.send('Maximum multiplier is 10')

        m = await ctx.send("pls wait am generating")
        try:
            b = BytesIO()
            async with aiohttp.ClientSession() as session:
                async with session.get(url) as r:
                    with wand.image.Image(file=BytesIO(await r.read())) as img:
                        img.transform(resize="400x400")
                        img.liquid_rescale(width=int(img.width * 0.5),
                                           height=int(img.height * 0.5),
                                           delta_x=multi,
                                           rigidity=0)
                        img.liquid_rescale(width=int(img.width * 1.5),
                                           height=int(img.height * 1.5),
                                           delta_x=2,
                                           rigidity=0)
                        img.save(file=b)
                        b.seek(0)

            await ctx.send(file=discord.File(b, filename="magik.png"))
            await m.delete()
        except:
            await m.edit(content="Unable to generate image. Provide a mention or valid URL.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号