Inky pHAT and Pi newb wanting help on displaying images

Hi, I am new to the Pi and I am new to Python. I have just purchased an Inky pHAT and have it installed on my Pi Zero W okay. I am following the instructions on https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-inky-phat, and have the software installed. I am now at the ‘Displaying images on Inky pHAT’ part of the tutorial and wish to convert an existing image using the instructions. I have done the ‘Git Clone’ bit, but when it says about finding the colour palette at ‘inky-phat/tools/Inky-pHAT.gpl,’ when I input that at terminal I am getting ‘permission denied.’ How do I proceed from here please? Also, I am not getting the next part either, SELECTING the Inky-pHAT.gpl colour palette. I can’t find it following the instructions.

I’d appreciate any and all help. Thanks for your patience and understanding.

You might also be able to grab it with: wget https://raw.githubusercontent.com/pimoroni/inky-phat/master/tools/Inky-pHAT.gpl or simply by visiting this URL and saving it from your browser: https://raw.githubusercontent.com/pimoroni/inky-phat/master/tools/Inky-pHAT.gpl

I have grabbed the content okay. it seemed to have worked both ways; gitclone and wget.

Then when I proceed to the next step, and input “inky-phat/tools/Inky-pHAT.gpl” at terminal, I get “bash: inky-phat/tools/Inky-pHAT.gpl: Permission denied.”

Without this I am unable to proceed to the next step, selecting the Inky-pHAT.gpl colour palette in GIMP.

The line

You’ll find the colour palette at inky-phat/tools/Inky-pHAT.gpl.

Means that’s where to find it, but if you type inky-phat/tools/Inky-pHAT.gpl in the terminal it’ll fail, since that’s a colour palette for GIMP and not an executable file.

You need to move on to:

Select Use custom palette, then click the Palette selection dialogue button. Select Palette file and then select the Inky-pHAT.gpl palette file from the GitHub repo that we just cloned.

Okay, thanks.

When selecting colour palette, where is the Palette selection dialogue button please? I cannot find that or the Palette file Inky-pHAT.gpl in GIMP.

I do apologise if I am being stupid, but I am new to all this.

Thanks for your understanding.

Okay, I can find the Palette Selection dialogue and have highlighted Inky-pHAT.gpl but I cannot then apply it to the image.

Scratch that I can’t import it. Please help.

It’s the fiddley little arrow on the right of the Palette Selection Dialogue. You need to go to “Palettes Menu” then “Import Palette” then finally click the radio next to “Palette File” and pick the file. I’m trying to grab some screenshots.

Switch image to Indexed Mode:

Use a custom palette and hit the Palette Selection Menu icon in the bottom right:

Then the tiny Configure this Tab arrow:

Then go to Import:

Choose file:

Navigate to Inky-pHAT.gpl

And open it:

Hitting import should take you back to here:

Now close the dialogue and re-open using the first two steps because GIMP is weird and wont show the Palette in the menu until the dialogue is reloaded :(

Hopefully this helps. I’ve got to dash!

Thank you very much, that has helped with creating the image.

Now when I follow the rest of the instructions I get this:

import inkyphat
from PIL import Image
inkyphat.set_image(Image.open(“/home/pi/Pictures/hellboycrap.png”))
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.7/dist-packages/inkyphat/init.py”, line 99, in set_image
_image.paste(image)
File “/usr/lib/python2.7/dist-packages/PIL/Image.py”, line 1334, in paste
self.im.paste(im, box)
ValueError: images do not match

Saved out as an 8bit png? Got naught but my phone for the next 4 hours or so, so I may not be much use!

Thanks Phil, I managed to get there in the end. I appreciate your patience
and understanding

Jon

2 Likes

Hello,
I also have issues to get a Gimp image onto my Inky pHat. I get this error (saved my image before as 8Bit RGB with the inky-phat-gpl-palette):

Traceback (most recent call last):
File “inkyphat.py”, line 23, in
inky_display.set_image(img)
File “/usr/local/lib/python2.7/dist-packages/inky/inky.py”, line 337, in set_image
self.buf = numpy.array(image, dtype=numpy.uint8).reshape((self.height, self.width))
ValueError: cannot reshape array of size 88192 into shape (104,212)

Which export option would be best in Gimp?

image

I would have imagined 8bpc RGB. Exactly what was your process?

Hi Shoe,
I have

  • created a 212x104 PNG,
  • loaded the palette into gimp,
  • turned the image mode to indexed (using the palette),
  • saved the image as 8bpc RGB PNG.

I use this python code:

from inky import InkyPHAT

inky_display = InkyPHAT("black")

from PIL import Image, ImageFont, ImageDraw
img = Image.open("/home/pi/212gz.png")

width, height = img.size
print(width, height)
print(img.format, img.size, img.mode)

So I discovered recently that the InkyWHAT library has an automated way of doing this without having to go via GIMP. Try this:

from inky import InkyPHAT

inky_display = InkyPHAT("black")

from PIL import Image, ImageFont, ImageDraw
img = Image.open("/home/pi/212gz.png")

# Create the palette
pal_img = Image.new("P", (1, 1))
pal_img.putpalette((255, 255, 255, 0, 0, 0, 255, 0, 0) + (0, 0, 0) * 252)

# Process the image using the palette
img = image.convert("RGB").quantize(palette=pal_img)

width, height = img.size
print(width, height)
print(img.format, img.size, img.mode)