From 11227c0db603841abbe428981d6c90663682c98e Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Sun, 17 Sep 2017 20:44:08 +0200 Subject: [PATCH] brother_ql_create: new CLI parameter --dither --- README.md | 4 +++- brother_ql/brother_ql_create.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2fa2f1b..fdac5d7 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ giving: usage: brother_ql_create [-h] [--model MODEL] [--label-size LABEL_SIZE] [--rotate {0,90,180,270}] [--threshold THRESHOLD] - [--no-cut] [--loglevel LOGLEVEL] + [--dither] [--no-cut] [--loglevel LOGLEVEL] image [outfile] positional arguments: @@ -85,6 +85,8 @@ giving: --threshold THRESHOLD, -t THRESHOLD The threshold value (in percent) to discriminate between black and white pixels. + --dither, -d Enable dithering when converting the image to b/w. If + set, --threshold is meaningless. --no-cut Don't cut the tape after printing the label. --loglevel LOGLEVEL Set to DEBUG for verbose debugging output to stderr. diff --git a/brother_ql/brother_ql_create.py b/brother_ql/brother_ql_create.py index 3dd1675..e62e700 100755 --- a/brother_ql/brother_ql_create.py +++ b/brother_ql/brother_ql_create.py @@ -31,6 +31,7 @@ def main(): parser.add_argument('--label-size', '-s', default='62', help='The label size (and kind) to use. Check available ones with `brother_ql_info list-label-sizes`.') parser.add_argument('--rotate', '-r', choices=('0', '90', '180', '270'), default='auto', help='Rotate the image (counterclock-wise) by this amount of degrees.') parser.add_argument('--threshold', '-t', type=float, default=70.0, help='The threshold value (in percent) to discriminate between black and white pixels.') + parser.add_argument('--dither', '-d', action='store_true', help='Enable dithering when converting the image to b/w. If set, --threshold is meaningless.') parser.add_argument('--no-cut', dest='cut', action='store_false', help="Don't cut the tape after printing the label.") parser.add_argument('--loglevel', type=lambda x: getattr(logging, x), default=logging.WARNING, help='Set to DEBUG for verbose debugging output to stderr.') args = parser.parse_args() @@ -52,7 +53,7 @@ def main(): qlr.exception_on_warning = True - create_label(qlr, args.image, args.label_size, threshold=args.threshold, cut=args.cut, rotate=args.rotate) + create_label(qlr, args.image, args.label_size, threshold=args.threshold, cut=args.cut, rotate=args.rotate, dither=args.dither) args.outfile.write(qlr.data)