What I want to do is a code which creates an image from a list of pixels. Here is the code.
from PIL import Image
data=open("data")
data2=data.read()
dat=print (data2)
img = Image.new('RGB', (10000,10000))
img.putdata([data2])
img.save("prova_v2.jpg")
And the error that output is:
Traceback (most recent call last):
File "C:\Users\cicles\Desktop\img - copia.py", line 5, in <module>
img.putdata([data2])
File "C:\Users\cicles\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\Image.py", line 1671, in putdata
self.im.putdata(data, scale, offset)
TypeError: color must be int or tuple
The data file that contains every RGB valour for every pixel inside an image. the format is [(R,G,B), (R,G,B), (R,G,B)] So a 2-line image with Red, Green and Blue pixels in the top row and Black, Grey and White pixels in the bottom row is like this:
[(255,0,0), (0,255,0), (0,0,255), (255,255,255), (128,128,128), (0,0,0)]

data? You can check the type ofdata2to make sure the content can be put intoimg. - Hao Lidata2in an additional array in the lineimg.putdata([data2]). That is probably not what you want. - physicalattraction