UnicornHAT show .png files?

I have an 8x8 .png file I would like to display on the UnicornHAT, I’ve never used python before for any projects so this is new to me and I’m struggling to work this on out on my own so I’ve come to ask for your help.

I’ve looked at the show_png.py example from Github but I’m still not sure how to implement this when using a single image that is only 8x8 pixels.

If anyone could explain this to me or provide a solution I’d greatly appreciate it!

the show_png.py should work straight off a 8x8 image as well as a matrix of pixel art.

The hardest part will be to get PIL on your system, which can be challenging. Other than that, place your png in the same folder as the script and edit the line reading:

img = Image.open('lofi.png')

the script could be simplified since you don’t need iterating through pixel art mapped to file, but if it works why bother?

Hi RougeM, I’ve tried changing the lofi.png within show_png.py to my own file named weather_rain.png (all these files are in the same directory) and running this in the terminal but nothing shows up on the unicorn, even the terminal does not print the pixel information like when the lofi.png file is used. I get no errors and the script completes running immediately taking me back to the normal command prompt.

This is the 8x8 image I am trying to use.

I also have an image with several 8x8 weather icons side by side that runs in the show_png.py script perfectly.
The script seems to like several 8x8 “blocks” within a single .png but does not like a single 8x8 “block” as a .png. Am I correct here or am I way off base?

I’ll have a look tomorrow - just looking at the code it seemed it would be OK with an image exactly 8x8, but I guess there’s a ‘gotcha’ I’m not seeing.

I seem to have solved the problem, unfortunately when exporting the images from photoshop it must have removed any surrounding transparency and this resulted in all my images being sized 8x7 and less, obviously meaning the code not outputting the image. By making sure all images used are actually 8x8 the example code works perfectly.

Completely down to error on my part, that will teach me for trusting the default export options in photoshop again. Sorry for wasting your time, I appreciate the help!

np, glad to hear you got to the bottom of the issue.