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)
评论列表
文章目录