I have some some data that I would like to visualize. Each byte of the source data roughly corresponds to a pixel value of the image.
我有一些我想要想象的数据。源数据的每个字节大致对应于图像的像素值。
What is the easiest way to generate an image file (bitmap?) using Python?
使用Python生成图像文件(位图?)的最简单方法是什么?
2 个解决方案
#1
You can create images with a list of pixel values using Pillow:
您可以使用Pillow创建包含像素值列表的图像:
from PIL import Image
img = Image.new('RGB', (width, height))
img.putdata(my_list)
img.save('image.png')
#2
#1
You can create images with a list of pixel values using Pillow:
您可以使用Pillow创建包含像素值列表的图像:
from PIL import Image
img = Image.new('RGB', (width, height))
img.putdata(my_list)
img.save('image.png')