From d76fb68696d4a5662e153b764ba95d29992b4505 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Tue, 7 Apr 2020 14:24:28 +0200 Subject: [PATCH 1/9] add printer api to requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 747d513..cd58deb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ Pillow==7.1.1 +brother-ql==0.9.4 -- 2.45.2 From 735dded69b0c8b9e295492585d67fb818400f5c2 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Tue, 7 Apr 2020 14:24:52 +0200 Subject: [PATCH 2/9] add shell wrapper --- address-label.py | 2 +- address-label.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 address-label.sh diff --git a/address-label.py b/address-label.py index 29e3014..c81bc18 100644 --- a/address-label.py +++ b/address-label.py @@ -11,4 +11,4 @@ d = ImageDraw.Draw(img) d.text((20,10), "Netz39 e.V., Leibnizstr. 32, 39104 Magdeburg", font=fnt0, fill=(0,0,0)) d.text((20,25), address.strip('\"'), font=fnt, fill=(0, 0, 0)) -img.save('pil_text_font.png') \ No newline at end of file +img.save('address-label.png') \ No newline at end of file diff --git a/address-label.sh b/address-label.sh new file mode 100644 index 0000000..a699617 --- /dev/null +++ b/address-label.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source venv/bin/activate +python address-label.py <&0 + +export BROTHER_QL_MODEL=QL-720NW !3678 +export BROTHER_QL_PRINTER=tcp://brw008092c0c4ca + +venv/bin/brother_ql print -l 62 address-label.png + +rm address-label.png \ No newline at end of file -- 2.45.2 From 240307f316230749b34ade55963781beee718e1e Mon Sep 17 00:00:00 2001 From: David Kilias Date: Tue, 7 Apr 2020 14:27:49 +0200 Subject: [PATCH 3/9] update readme --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 522c08c..1ec25c5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,19 @@ -### Usage +## Usage + +### Generate Address-Label ```bash echo "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg" | python address-label.py jq -r .stammdaten.address_label ../Vorstand/stammdaten-formular/example.json | python address-label.py +``` + +### Print label + +Needs to be in the same network as the printer. + +```bash +echo "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg" | address-label.sh + +jq -r .stammdaten.address_label ../Vorstand/stammdaten-formular/example.json | address-label.sh ``` \ No newline at end of file -- 2.45.2 From 20dea73b12b52899bfff59fcd5aa210ca63e9edf Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 10 Apr 2020 15:17:58 +0200 Subject: [PATCH 4/9] use variables in usage examples --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ec25c5..e23109c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ ```bash echo "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg" | python address-label.py -jq -r .stammdaten.address_label ../Vorstand/stammdaten-formular/example.json | python address-label.py +MEMBERFILE="../Vorstand/stammdaten-formular/example.json" +jq -r .stammdaten.address_label $MEMBERFILE | python address-label.py ``` ### Print label @@ -15,5 +16,6 @@ Needs to be in the same network as the printer. ```bash echo "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg" | address-label.sh -jq -r .stammdaten.address_label ../Vorstand/stammdaten-formular/example.json | address-label.sh +MEMBERFILE="../Vorstand/stammdaten-formular/example.json" +jq -r .stammdaten.address_label $MEMBERFILE | address-label.sh ``` \ No newline at end of file -- 2.45.2 From 2bf16f6a8d1d0c3e6316dfde1135c2a0471ffa42 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 10 Apr 2020 15:18:31 +0200 Subject: [PATCH 5/9] install python requirements in address-label.sh --- address-label.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/address-label.sh b/address-label.sh index a699617..2419b76 100644 --- a/address-label.sh +++ b/address-label.sh @@ -1,6 +1,8 @@ #!/bin/bash source venv/bin/activate +pip install -r requirements.txt + python address-label.py <&0 export BROTHER_QL_MODEL=QL-720NW !3678 -- 2.45.2 From eedff1c97ef12a0db493655ed540202aee116ad6 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 10 Apr 2020 16:10:58 +0200 Subject: [PATCH 6/9] make shellscript executable --- address-label.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 address-label.sh diff --git a/address-label.sh b/address-label.sh old mode 100644 new mode 100755 -- 2.45.2 From 8946f6eba7b625e26be4ab5d16eca80145c2a06c Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 10 Apr 2020 16:11:21 +0200 Subject: [PATCH 7/9] fix fontsizes and label dimensions --- address-label.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/address-label.py b/address-label.py index c81bc18..b49d0c3 100644 --- a/address-label.py +++ b/address-label.py @@ -3,12 +3,12 @@ import sys address = "".join(sys.stdin.readlines()) -img = Image.new('RGB', (696, 160), color = (255, 255, 255)) +img = Image.new('RGB', (696, 220), color = (255, 255, 255)) -fnt0 = ImageFont.truetype('fonts/OpenSans-Regular.ttf', 14) -fnt = ImageFont.truetype('fonts/OpenSans-Regular.ttf', 32) +fnt0 = ImageFont.truetype('fonts/OpenSans-Regular.ttf', 24) +fnt = ImageFont.truetype('fonts/OpenSans-Regular.ttf', 54) d = ImageDraw.Draw(img) -d.text((20,10), "Netz39 e.V., Leibnizstr. 32, 39104 Magdeburg", font=fnt0, fill=(0,0,0)) +d.text((20,5), "Netz39 e.V., Leibnizstr. 32, 39104 Magdeburg", font=fnt0, fill=(0,0,0)) d.text((20,25), address.strip('\"'), font=fnt, fill=(0, 0, 0)) img.save('address-label.png') \ No newline at end of file -- 2.45.2 From bc870e3a607f634f1f4b70c84e38d43e4e38f49c Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 10 Apr 2020 16:11:36 +0200 Subject: [PATCH 8/9] fix usage examples --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e23109c..437a1c1 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ jq -r .stammdaten.address_label $MEMBERFILE | python address-label.py Needs to be in the same network as the printer. ```bash -echo "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg" | address-label.sh +echo "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg" | ./address-label.sh MEMBERFILE="../Vorstand/stammdaten-formular/example.json" -jq -r .stammdaten.address_label $MEMBERFILE | address-label.sh +jq -r .stammdaten.address_label $MEMBERFILE | ./address-label.sh ``` \ No newline at end of file -- 2.45.2 From 5acedddfecc9f1a3eeb751d746ff61f84d1636c9 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 10 Apr 2020 16:21:07 +0200 Subject: [PATCH 9/9] remove c'n'p artefact --- address-label.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/address-label.sh b/address-label.sh index 2419b76..dda878f 100755 --- a/address-label.sh +++ b/address-label.sh @@ -5,7 +5,7 @@ pip install -r requirements.txt python address-label.py <&0 -export BROTHER_QL_MODEL=QL-720NW !3678 +export BROTHER_QL_MODEL=QL-720NW export BROTHER_QL_PRINTER=tcp://brw008092c0c4ca venv/bin/brother_ql print -l 62 address-label.png -- 2.45.2