functions.py 文件源码

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

项目:poseidon 作者: sidus-dev 项目源码 文件源码
def data2pixbuf(data, size):

    fp = Image.open(BytesIO(data))
    output = BytesIO()
    fp.thumbnail(size, Image.ANTIALIAS)
    fp.save(output, format="png")
    data = output.getvalue()
    output.close()

    loader = GdkPixbuf.PixbufLoader()
    loader.write(data)
    loader.close()
    pixbuf = loader.get_pixbuf()

    if pixbuf:
        if (pixbuf.get_width(), pixbuf.get_height()) != size: return None
        else: return pixbuf
    else: return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号