怎么把wand.image.Image转换成PIL.Image? [英] How to convert wand.image.Image to PIL.Image?

查看:297
本文介绍了怎么把wand.image.Image转换成PIL.Image?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整天都在这个问题上,没有在堆栈溢出中看到答案!

I spent whole day on this problem and did not see answer in stack overflow!

我尝试了这个,但是没有用:

I tried this but did not work:

    >> pil_image = Image.frombytes('RGBA', wand_image.size, wand_image.make_blob(format='png'), 'raw')

    ValueError: not enough image data

我感谢每一个解决方案.

I appreciate every solution.

推荐答案

这对我有用:

    img_buffer = numpy.asarray(bytearray(wand_img.make_blob(format='png')), dtype='uint8')
    bytesio = io.BytesIO(img_buffer)
    pil_img = PIL.Image.open(bytesio)

这篇关于怎么把wand.image.Image转换成PIL.Image?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆