From 3c73043509c5c7b2a5e385fcbb5de1a341b4314f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 6 Jan 2018 21:47:14 +1100 Subject: [PATCH] Simplified use of sys.argv --- src/PIL/SpiderImagePlugin.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PIL/SpiderImagePlugin.py b/src/PIL/SpiderImagePlugin.py index 5e5dde5a6..013560fe9 100644 --- a/src/PIL/SpiderImagePlugin.py +++ b/src/PIL/SpiderImagePlugin.py @@ -286,7 +286,7 @@ Image.register_save(SpiderImageFile.format, _save_spider) if __name__ == "__main__": - if not sys.argv[1:]: + if len(sys.argv) < 2: print("Syntax: python SpiderImagePlugin.py [infile] [outfile]") sys.exit() @@ -295,10 +295,6 @@ if __name__ == "__main__": print("input image must be in Spider format") sys.exit() - outfile = "" - if len(sys.argv[1:]) > 1: - outfile = sys.argv[2] - im = Image.open(filename) print("image: " + str(im)) print("format: " + str(im.format)) @@ -307,7 +303,9 @@ if __name__ == "__main__": print("max, min: ", end=' ') print(im.getextrema()) - if outfile != "": + if len(sys.argv) > 2: + outfile = sys.argv[2] + # perform some image operation im = im.transpose(Image.FLIP_LEFT_RIGHT) print(