Hello! I am trying to create a thermal printer fortune teller - I've made similar projects in the past with an Arduino + thermal printer using simple text strings as fortunes. However, this time I would like to print out a random image - so I've shifted over to a Raspberry Pi, and using this USB Thermal Printer. I'm a bit of a newbie when it comes to Raspberry Pi - and especially Python - but I feel like I'm close to a solution, just not quite there yet.
I noticed most of the Adafruit Thermal Printer tutorials for the Raspberry Pi were for the TTL version, and didn't really deal with printing images, mostly just text. I followed this YouTube video on installing the Raspberry Pi OS, connecting the thermal printer via USB, installing CUPS, setting it as the default printer - and I was able to print out both the stock Raspberry Pi logo along with some custom images using the "lp -o fit-to-page /usr/share/raspberrypi-artwork/raspberry-pi-logo.png" command line prompt.
I've also mostly figured out the button side in Python. This is my first time working with Python, so I've been following this example on reading a button press, and it's been successful.
Where I am struggling is how to send a command through python for the printer to print an image. I found this example, but I encounter problems with the "printer_name=printers.keys()[0]" line. I have a suspicion this is something to do with Python 2 vs. Python 3, but I'm in way over my head there.
Any tips on sending a random image via CUPS to a thermal printer using Python? Is it possible to send something similar to the "lp -o fit-to-page /usr/share/raspberrypi-artwork/raspberry-pi-logo.png" command line prompt in python? Thank you for any help!