-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_display.py
53 lines (40 loc) · 1.18 KB
/
image_display.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import argparse
import pathlib
import sys
from inky_drivers.inky_uc8159_mod import Inky as InkyUC8159
from inky_drivers.inky_ac0735c1a_mod import Inky as Inky_AC0735c1a
from PIL import Image
parser = argparse.ArgumentParser()
parser.add_argument(
"--saturation", "-s", type=float, default=0.5, help="Colour palette saturation"
)
parser.add_argument("--file", "-f", type=pathlib.Path, help="Image file")
parser.add_argument(
"--device",
"-d",
type=str,
default="Impression5-7",
help="Inky device to use, "
"e.g. Impression4, Impression7-3 or Impression5-7 (default)",
)
args, _ = parser.parse_known_args()
if args.device == "Impression4":
inky = InkyUC8159(device_type="Impression4")
elif args.device == "Impression7-3":
inky = Inky_AC0735c1a()
else:
inky = InkyUC8159(device_type="Impression5-7")
saturation = args.saturation
if not args.file:
print(
f"""Usage:
{sys.argv[0]} --file image.png (--saturation 0.5)"""
)
sys.exit(1)
image = Image.open(args.file)
resizedimage = image.resize(inky.resolution)
try:
inky.set_image(resizedimage, saturation=saturation)
except TypeError:
inky.set_image(resizedimage)
inky.show()