From 73f870b4df9f51f1600433c6c64dc5afe2091613 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sun, 4 Feb 2024 16:46:53 +0100 Subject: [PATCH] fix use output filename --- imagegenerator/generate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/imagegenerator/generate.py b/imagegenerator/generate.py index a17d190..91ef0a8 100644 --- a/imagegenerator/generate.py +++ b/imagegenerator/generate.py @@ -16,11 +16,14 @@ parser.add_argument('-i', '--invert', action='store_true') args = parser.parse_args() print(args.filename, args.output, args.format,args.verbose,args.invert) +outputfilename="result.txt" +if args.output is not None: + outputfilename=args.output im = Image.open(args.filename) # Can be many different formats. pix = im.load() print(im.size) # Get the width and hight of the image for iterating over -print(pix[10,10]) # Get the RGBA Value of the a pixel of an image +#print(pix[10,10]) # Get the RGBA Value of the a pixel of an image output_pre="" output_col_preL="" @@ -63,7 +66,7 @@ def calculateDistance(x1,y1,x2,y2): dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2) return dist -with open('result.txt', 'w') as f: +with open(outputfilename, 'w') as f: f.write(output_pre) for x in range(im.size[0]): f.write(output_col_preL)