Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/python/bin/gnuboat-splashscreen

    rcfdd201 r6f09609  
    2121import getopt
    2222try:
    23   from PIL import Image
    24   from PIL import ImageOps
    25   from EPD import EPD
    26   epdEnabled = True
     23    from PIL import Image
     24    from PIL import ImageOps
     25    from EPD import EPD
     26    epdEnabled = True
    2727except:
    28   epdEnabled = False
     28    epdEnabled = False
     29
    2930
    3031def 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
    3739
    3840def 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()
    4547
    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)
    5348
    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"
     49def 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)
    6256
    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"
    6865
    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)
    7271
    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)
    7679
    7780if __name__ == "__main__":
    78   main(sys.argv[1:])
     81    main(sys.argv[1:])
Note: See TracChangeset for help on using the changeset viewer.