image.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def resize(message: discord.Message, image_arg: image, resolution: parse_resolution, *options,
                 extension: str.lower=None):
    """ Resize an image with the given resolution formatted as `<width>x<height>`
    or `*<scale>` with an optional extension. """
    if extension:
        image_arg.set_extension(extension)

    # Generate a new image based on the scale
    if resolution[1] == 0:
        w, h = image_arg.object.size
        scale = resolution[0]
        assert w * scale < 3000 and h * scale < 3000, "**The result image must be less than 3000 pixels in each axis.**"
        resolution = (int(w * scale), int(h * scale))

    # Resize and upload the image
    image_arg.modify(Image.Image.resize, resolution, Image.NEAREST if "-nearest" in options else Image.ANTIALIAS)
    await send_image(message, image_arg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号