Clear and show image in PIMORONI Inky Impression 7 Color Display with python
The following code is a combination of the examples provided by PIMORONI.
#!/usr/bin/env python3
# File Name: show.py
#
# Usage 1: Show a selected image
#
# python3 show.py foto1.jpg
# python3 show.py /home/pi/foto1.jpg
#
# Usage 2: Show a random image
#
# ls /home/pi/*.jpg | sort -R | tail -1 | while read file; do python3 show.py $file; done
import time
import sys
from inky.inky_uc8159 import Inky, CLEAN
from PIL import Image
from inky.inky_uc8159 import Inky
inky = Inky()
saturation = 0.6
# Clear display
for _ in range(2):
for y in range(inky.height - 1):
for x in range(inky.width - 1):
inky.set_pixel(x, y, CLEAN)
inky.show()
time.sleep(1.0)
# Load image
if len(sys.argv) == 1:
print("""
Usage: {file} image-file
""".format(file=sys.argv[0]))
sys.exit(1)
image = Image.open(sys.argv[1])
if len(sys.argv) > 2:
saturation = float(sys.argv[2])
inky.set_image(image, saturation=saturation)
inky.show()