From 1e6036cde4d78a5f353b23ea8648e8dd654a4b67 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sun, 31 Dec 2023 15:29:28 +0100 Subject: [PATCH] add invert flag --- imagegenerator/generate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imagegenerator/generate.py b/imagegenerator/generate.py index 5ae8772..a17d190 100644 --- a/imagegenerator/generate.py +++ b/imagegenerator/generate.py @@ -11,9 +11,10 @@ parser.add_argument('filename') # positional argument parser.add_argument('-o', '--output') # option that takes a value parser.add_argument('-f', '--format', choices=['firmware','nodered','nodered_int'], default='firmware', help='Output format') # option that takes a value parser.add_argument('-v', '--verbose', action='store_true') # on/off flag +parser.add_argument('-i', '--invert', action='store_true') args = parser.parse_args() -print(args.filename, args.output, args.format,args.verbose) +print(args.filename, args.output, args.format,args.verbose,args.invert) im = Image.open(args.filename) # Can be many different formats. @@ -73,6 +74,9 @@ with open('result.txt', 'w') as f: columnValue=0 for y in reversed(range(im.size[1])): c = pix[x,y] #get pixel + if args.invert: + c=255-c + if (c[0]>127): if output_col_write_binary_flag: f.write("1")