I have the same code (different file name) but the error I get is that I cannot use the argument pixels[x,y] for Chr() to write to a binary file
I have been trying to make this work and have not figured out how to do it yet.
from PIL import Image
image = Image.open("Margarita3.png")
pixels = image.load()
out_file = open("Margarita3.bin", "wb")
for y in range(150):
for x in range(200):
try:
out_file.write(chr(pixels[x, y]))
except IndexError:
out_file.write(chr(0))
Here is the error message:
Traceback (most recent call last):
File "C:\Users\Nicky\Desktop\tolaptop\wincupl_vga_timings\convert.py", line
11, in <module>
out_file.write(chr(pixels[x,y]))
TypeError: an integer is required