displayhatmini-python icon indicating copy to clipboard operation
displayhatmini-python copied to clipboard

I can't figure out the syntax to display to the display a .jpg via Pillow, its not clear in the backlight example

Open snarflakes opened this issue 3 years ago • 1 comments
trafficstars

I would super appreciate the python syntax for displaying a .jpg using Pillow. Perhaps in the backlight example? Something super brief would be awesome. The old ST module used: disp.image(X).

thanks again, beautiful screen.

Snarflakes

snarflakes avatar Apr 06 '22 19:04 snarflakes

Hi @snarflakes, try something like this:

width = DisplayHATMini.WIDTH
height = DisplayHATMini.HEIGHT
buffer = Image.new("RGB", (width, height))
displayhatmini = DisplayHATMini(buffer, backlight_pwm=True)

with Image.open("myFile.jpg") as im:
    buffer.paste(
        im.resize((width // 2, height // 2)), 
        (width // 4, height // 4)
    )

displayhatmini.display()

jftsang avatar Mar 27 '23 20:03 jftsang