Skip to content

Commit

Permalink
classify the display-an-image script
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed May 10, 2021
1 parent 9822708 commit e3b568b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/display.py
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
from inky import InkyWHAT
from PIL import Image

class Display:
DEFAULT_MODE = 'red'

def __init__(self, image, mode=DEFAULT_MODE):
self.what = InkyWHAT(mode)
self.what.set_image(image)

@classmethod
def open(cls, path, mode=DEFAULT_MODE):
return cls(Image.open(path), mode=mode)

def show(self):
self.what.show()


if __name__ == '__main__':
from argparse import ArgumentParser

parser = ArgumentParser(__file__)
parser.add_argument(
'filename',
help='a 300x400 image suitable for sending to the wHAT',
)
parser.add_argument(
'--mode',
default=Display.DEFAULT_MODE,
choices=['red', 'black'],
help='whether to load the image in b+w+red or b+w mode'
)
args = parser.parse_args()

display = Display.open(args.filename, args.mode)
display.show()

0 comments on commit e3b568b

Please sign in to comment.