From 9da7e0ba28ddfc52b0aa1993541ac11bb8426785 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Tue, 13 Dec 2016 15:51:58 +0100 Subject: [PATCH] fixing the --threshold setting (given in percent) --- brother_ql/brother_ql_create.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/brother_ql/brother_ql_create.py b/brother_ql/brother_ql_create.py index c810900..105ec1a 100755 --- a/brother_ql/brother_ql_create.py +++ b/brother_ql/brother_ql_create.py @@ -89,7 +89,9 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, **kwargs): im = new_im else: raise NotImplementedError("Label kind %s not implemented yet." % label_specs['kind']) - im = im.point(lambda p: p > threshold and 255, mode="1") + + threshold = min(255, max(0, int(threshold/100.0 * 255))) # from percent to pixel val + im = im.point(lambda x: 0 if x < threshold else 255, mode="1") try: qlr.add_switch_mode()