python how to make a png

Solutions on MaxInterview for python how to make a png by the best coders in the world

showing results for - "python how to make a png"
Michela
24 Aug 2020
1import png
2s = ['110010010011',
3     '101011010100',
4     '110010110101',
5     '100010010011']
6s = [[int(c) for c in row] for row in s]
7
8w = png.Writer(len(s[0]), len(s), greyscale=True, bitdepth=1)
9f = open('png.png', 'wb')
10w.write(f, s)
11f.close()
12
13# https://pypng.readthedocs.io/en/latest/ex.html