utils.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def convert_image_object(image, format: str="PNG", **params):
    """ Saves a PIL.Image.Image object to BytesIO buffer. Effectively
    returns the byte-like object for sending through discord.Client.send_file.

    :param image: PIL.Image.Image: object to convert.
    :param format: The image format, defaults to PNG.
    :param params: Any additional parameters sent to the writer.
    :return: BytesIO: the image object in bytes.
    """
    buffer = BytesIO()
    image.save(buffer, format, **params)
    buffer.seek(0)
    return buffer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号