在Python中,如何从一些源数据轻松生成图像文件?

Jes*_*ogt 19 python data-visualization image

我有一些我想要想象的数据.源数据的每个字节大致对应于图像的像素值.

使用Python生成图像文件(位图?)的最简单方法是什么?

Arm*_*das 30

您可以使用Pillow创建包含像素值列表的图像:

from PIL import Image

img = Image.new('RGB', (width, height))
img.putdata(my_list)
img.save('image.png')
Run Code Online (Sandbox Code Playgroud)

  • 更有用的例子:http://stackoverflow.com/questions/12062920/how-do-i-create-an-image-in-pil-using-a-list-of-rgb-tuples (2认同)

scv*_*lex 5

看看PILpyGame。它们都允许您在画布上绘图,然后将其保存到文件中。