fix use output filename

This commit is contained in:
interfisch 2024-02-04 16:46:53 +01:00
parent e6948cea16
commit 73f870b4df
1 changed files with 5 additions and 2 deletions

View File

@ -16,11 +16,14 @@ parser.add_argument('-i', '--invert', action='store_true')
args = parser.parse_args() args = parser.parse_args()
print(args.filename, args.output, args.format,args.verbose,args.invert) 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. im = Image.open(args.filename) # Can be many different formats.
pix = im.load() pix = im.load()
print(im.size) # Get the width and hight of the image for iterating over 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_pre=""
output_col_preL="" output_col_preL=""
@ -63,7 +66,7 @@ def calculateDistance(x1,y1,x2,y2):
dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2) dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
return dist return dist
with open('result.txt', 'w') as f: with open(outputfilename, 'w') as f:
f.write(output_pre) f.write(output_pre)
for x in range(im.size[0]): for x in range(im.size[0]):
f.write(output_col_preL) f.write(output_col_preL)