How to convert wand.image.Image to PIL.Image?

旧城冷巷雨未停 提交于 2019-12-06 09:35:16

问题


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.


回答1:


This worked for me:

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


来源:https://stackoverflow.com/questions/52536843/how-to-convert-wand-image-image-to-pil-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!