Inkybit image to raw help needed

Hi, I’m trying out the new inkybit with a microbit (v2). I can use it fine with the makecode blocks, but I want to make some pixel images for it like the one it ships with and as far as I can tell this means needing to use micropython.

I’m very new to using python for the microbit and I’ve been working on this for hours and getting nowhere fast. From what I can tell, I’m supposed to use this image-to-raw python programme (micropython-inkybit/ at master · pimoroni/micropython-inkybit · GitHub) to convert a png to a bin file and then upload this bin file along with the inkybit library in the microbit python editor: Python Editor for micro:bit and then use the code inkybit.draw_bin(“filename.bin”)

As an aside, when I test micropython code on the microbit to generate text, I keep getting a 090 error code and sad face flashing on the LED display, although the text displays fine on the inkybit.

Back to trying to generate the raw image: I’m on a Windows 10 machine, using python 3.9 and using IDLE with the code below. The code runs but I’m not successfully managing to save a bin file anywhere. I realise I’m probably making a really daft mistake. Any thoughts very gratefully received and thank you for your time.

#!/usr/bin/env python3
from PIL import Image
import numpy
import sys
import pathlib

Takes a 250x122 pixel 8-bit PNG image and
converts it into a .bin for display on inky:bit.
Use with: inkybit.draw_bin(“filename.bin”)

COLS = 136
ROWS = 250

if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} image.png")

filename = pathlib.Path(sys.argv[1])

source =“inkybit.png”)

if source.size != (250, 122):
print(f"Image must be 250x122 pixels!")

image =“P”, (ROWS, COLS), 1)

image.paste(source, (0, 6))

image = image.rotate(-90, expand=True)

pixels = numpy.array(list(image.tobytes()))

buf_a = numpy.packbits(pixels == 0).tobytes()
buf_b = numpy.packbits(pixels == 2).tobytes()

out_filename = filename.with_suffix(“newinkybit.bin”)
print(f"Saving as {out_filename}")
with open(out_filename, “wb”) as f:
f.write(buf_a + buf_b)

Do you get any error messages displayed by the program?
out_filename = filename.with_suffix(“newinkybit.bin”)
should be just
out_filename = filename.with_suffix(".bin”)
but I guess that’s a change you made to try and make it work.
It worked for me with the sample nomnom.png image.
I ran it from the command line rather than Idle

 Volume in drive C has no label.
 Volume Serial Number is 3837-B821

 Directory of C:\temp\image

13/01/2021  19:11               973
13/01/2021  19:09             2,194 nomnom.png

Run with python nomnom.png

Saving as nomnom.bin

 Directory of C:\temp\image

13/01/2021  19:11               973
13/01/2021  19:39             8,500 nomnom.bin <--
13/01/2021  19:09             2,194 nomnom.png

Thanks so much for your help. I’m going to try again from the command line.