Basic Image processing with Pillow

I didnt find a way to simply display a generated string in homeassistant and in appdaemon frontend.
So I thought pillow with fonts is the solution.

Python script

from PIL import Image, ImageDraw, ImageFont

output = 'pillow not working in' 

img ='RGB', (400, 250), color = (255, 255, 255))
font = ImageFont.truetype("/config/scripts/arial.ttf", 22) 
d = ImageDraw.Draw(img)
d.text((18,18), output, font=font, fill=(0,0,0))'/config/www/test.png')


testpillow: python3 "/config/scripts/"

After calling shellcommand i can use this image in


- platform: local_file
  name: test_output
  file_path: /config/www/test.png

So i can use this ‘camera’ everywhere in groups.yaml and i can use it in appdeamon for displaying infos generated from SQL or a shell command etc.

But …

Traceback (most recent call last):
  File "", line 7, in <module>
    font = ImageFont.truetype("/config/scripts/arial.ttf", 12)
  File "/usr/lib/python3.6/site-packages/PIL/", line 260, in truetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/lib/python3.6/site-packages/PIL/", line 135, in __init__
    if core.HAVE_RAQM:
  File "/usr/lib/python3.6/site-packages/PIL/", line 39, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

apk add py-pillow

fix this error.

So i need to add py-pillow after every update - bad.

Is there another way / bettter way i could achieve this: display infotxt in homeassistant + appdaemon ?

1 Like

Hi, any progress on your quest?
I tried to replicate your suggestion with

apk add py-pillow

however running test_image still outputs the same error.

1 Like