from pil import Image
def newImg():
img = Image.new('RGB', (100, 100))
img.putpixel((30, 60), (155, 155, 55))
img.save(r'C:UserslenovoDesktopsqr.png')
return img
newImg()
import png
s = ['110010010011',
'101011010100',
'110010110101',
'100010010011']
s = [[int(c) for c in row] for row in s]
w = png.Writer(len(s[0]), len(s), greyscale=True, bitdepth=1)
f = open('png.png', 'wb')
w.write(f, s)
f.close()
# https://pypng.readthedocs.io/en/latest/ex.html