+-
python – 从字节文件打开PIL图像
我有 this image大小128 x 128像素和RGBA存储为我的内存中的字节值.但

from PIL import Image

image_data = ... # byte values of the image
image = Image.frombytes('RGBA', (128,128), image_data)
image.show()

抛出异常

ValueError: not enough image data

为什么?我究竟做错了什么?

最佳答案
你可以试试这个:

image = Image.frombytes('RGBA', (128,128), image_data, 'raw')

Source Code:

06001

点击查看更多相关文章

转载注明原文:python – 从字节文件打开PIL图像 - 乐贴网