Changeset 6f09609 for src/python/bin/gnuboat-splashscreen
- Timestamp:
- Aug 6, 2017, 3:53:21 PM (9 years ago)
- Branches:
- 0.5, app-cordova, debian/bullseye, debian/jessie, master
- Children:
- 37d2e9d, 8befa17, d51c76c
- Parents:
- 1efcac7
- File:
-
- 1 edited
-
src/python/bin/gnuboat-splashscreen (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/python/bin/gnuboat-splashscreen
r1efcac7 r6f09609 21 21 import getopt 22 22 try: 23 from PIL import Image24 from PIL import ImageOps25 from EPD import EPD26 epdEnabled = True23 from PIL import Image 24 from PIL import ImageOps 25 from EPD import EPD 26 epdEnabled = True 27 27 except: 28 epdEnabled = False 28 epdEnabled = False 29 29 30 30 31 def displayImage(epd, imageFilePath): 31 image = Image.open(imageFilePath) 32 image = ImageOps.grayscale(image) 33 imageResized = image.resize((epd.width, epd.height)) 34 imageBlackWhite = imageResized.convert("1", dither=Image.FLOYDSTEINBERG) 35 epd.display(imageBlackWhite) 36 epd.update() 32 image = Image.open(imageFilePath) 33 image = ImageOps.grayscale(image) 34 imageResized = image.resize((epd.width, epd.height)) 35 imageBlackWhite = imageResized.convert("1", dither=Image.FLOYDSTEINBERG) 36 epd.display(imageBlackWhite) 37 epd.update() 38 37 39 38 40 def usage(): 39 print "Usage of gnuboat-splashscreen:"40 print " gnuboat-splashscreen [-h] -i PATH_TO_IMAGE_TO_DISPLAY"41 print ""42 print " -h --help Print this help"43 print " -i --image Path to the image, which should be displayed"44 sys.exit()41 print "Usage of gnuboat-splashscreen:" 42 print " gnuboat-splashscreen [-h] -i PATH_TO_IMAGE_TO_DISPLAY" 43 print "" 44 print " -h --help Print this help" 45 print " -i --image Path to the image, which should be displayed" 46 sys.exit() 45 47 46 def main(argv):47 image = ""48 try:49 opts, args = getopt.getopt(argv, "hi:", ["help", "image="])50 except getopt.GetoptError:51 usage()52 sys.exit(2)53 48 54 for option, argument in opts: 55 if option == ("-h", "--help"): 56 usage() 57 sys.exit() 58 elif option in ("-i", "--image"): 59 image = argument 60 else: 61 assert False, "unhandled option" 49 def main(argv): 50 image = "" 51 try: 52 opts, args = getopt.getopt(argv, "hi:", ["help", "image="]) 53 except getopt.GetoptError: 54 usage() 55 sys.exit(2) 62 56 63 if not os.path.exists(image): 64 print "Image %s not found" % image 65 print "" 66 usage() 67 sys.exit(2) 57 for option, argument in opts: 58 if option == ("-h", "--help"): 59 usage() 60 sys.exit() 61 elif option in ("-i", "--image"): 62 image = argument 63 else: 64 assert False, "unhandled option" 68 65 69 if not epdEnabled: 70 print "Could not initialize EPD or PIL python packages" 71 sys.exit(2) 66 if not os.path.exists(image): 67 print "Image %s not found" % image 68 print "" 69 usage() 70 sys.exit(2) 72 71 73 epd = EPD() 74 epd.clear() 75 displayImage(epd, image) 72 if not epdEnabled: 73 print "Could not initialize EPD or PIL python packages" 74 sys.exit(2) 75 76 epd = EPD() 77 epd.clear() 78 displayImage(epd, image) 76 79 77 80 if __name__ == "__main__": 78 main(sys.argv[1:])81 main(sys.argv[1:])
Note:
See TracChangeset
for help on using the changeset viewer.
