/ Pi_Matrix_Cube / imageviewer.py
imageviewer.py
1 # SPDX-FileCopyrightText: 2022 Phillip Burgess for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 """ 6 Very minimal image viewer for 6X square RGB LED matrices. 7 8 usage: sudo python imageviewer.py [filename] 9 """ 10 11 import time 12 import sys 13 from rgbmatrix import RGBMatrix, RGBMatrixOptions 14 from PIL import Image 15 16 if len(sys.argv) < 2: 17 sys.exit("Requires an image argument") 18 else: 19 image_file = sys.argv[1] 20 21 image = Image.open(image_file).convert("RGB") 22 23 # Hardcoded matrix config; commandline args ignored 24 options = RGBMatrixOptions() 25 options.rows = 64 26 options.cols = 64 27 options.chain_length = 6 28 options.parallel = 1 29 options.hardware_mapping = "adafruit-hat-pwm" 30 options.gpio_slowdown = 4 31 32 matrix = RGBMatrix(options=options) 33 34 # Scale image to fit 6X matrix chain 35 image.thumbnail((matrix.width, matrix.height), Image.ANTIALIAS) 36 37 matrix.SetImage(image) 38 39 try: 40 print("Press CTRL-C to stop.") 41 while True: 42 time.sleep(100) 43 except KeyboardInterrupt: 44 sys.exit(0)