From b85f7305a74012990471193bd6c7ebe8ec463307 Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 26 Feb 2024 12:38:14 +0100 Subject: [PATCH] Rename and update a4 label generator --- generate_labels.py | 47 - generate_labels_a4.py | 83 + homebox_label_template.svg | 23606 ----------------------------------- 3 files changed, 83 insertions(+), 23653 deletions(-) delete mode 100755 generate_labels.py create mode 100755 generate_labels_a4.py delete mode 100644 homebox_label_template.svg diff --git a/generate_labels.py b/generate_labels.py deleted file mode 100755 index 0b29665..0000000 --- a/generate_labels.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import svgwrite -import os - -lost_and_found_content = "Found? https://l3d.ch/kontakt" -asset_content_prefix = "000-" - -def create_a4_svg(output_filename): - # A4 size in millimeters - a4_width = '210mm' - a4_height = '297mm' - - # Create SVG document (A4) - dwg = svgwrite.Drawing(output_filename, size=(a4_width, a4_height), profile='tiny') - - # Add your content or elements to the SVG here - # For example, you can add a rectangle as a placeholder - # dwg.add(dwg.rect(insert=(10, 10), size=(a4_width_svg - 20, a4_height_svg - 20), fill="white", stroke="black")) - asset_content_suffix=0 - for x in range(0,3): - for y in range(0,10): - print(f"Create Label: X={x}, Y={y} - {asset_content_prefix}{asset_content_suffix:03}") - # white bg for label - dwg.add(dwg.rect(insert=(f'{x*70}mm', f'{y*29.7}mm'), size=('70mm', '29.7mm'), fill="white", stroke="none")) - # asset number - asset_element = dwg.text(str(f"{asset_content_prefix}{asset_content_suffix:03}"), insert=(f'{x*70+29.7}mm', f'{y*29.7+10}mm'), font_size="37px", font_family="Lato", fill="black") - dwg.add(asset_element) - # lost and found - lost_and_found_element = dwg.text(lost_and_found_content, insert=(f'{x*70+29.7}mm', f'{y*29.7+15}mm'), font_size="11.3px", font_family="Lato", fill="black") - dwg.add(lost_and_found_element) - # freitextfeld - dwg.add(dwg.rect(insert=(f'{x*70+29.7+0.5}mm', f'{y*29.7+28.2}mm'), size=('38.3mm', '0.2mm'), fill="grey", stroke="none")) - - # create qr-code - os.system(f'qrencode -t svg -l H -s 42 "https://i.l3d.ch/a/{asset_content_prefix}{asset_content_suffix:03}" -o /tmp/homebox-{asset_content_prefix}{asset_content_suffix:03}.svg') - # import - qr_code_svg = svgwrite.image.Image(f'/tmp/homebox-{asset_content_prefix}{asset_content_suffix:03}.svg', insert=(f'{x*70}mm', f'{y*29.7}mm'), size=('29.7mm', '29.7mm')) - dwg.add(qr_code_svg) - asset_content_suffix+= 1 - - # Save the SVG document - dwg.save() - -if __name__ == "__main__": - create_a4_svg("output_a4.svg") - diff --git a/generate_labels_a4.py b/generate_labels_a4.py new file mode 100755 index 0000000..34d75f2 --- /dev/null +++ b/generate_labels_a4.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Script to generate hobebox A4 Labels +""" +import os +import svgwrite + +LOST_AND_FOUND_STRING = "Found? https://l3d.ch/kontakt" +ASSET_CONTENT_PREFIX = "000-" + +def create_a4_svg(output_filename): + """ + Create A4 SVG + """ + # A4 size in millimeters + a4_width = '210mm' + a4_height = '297mm' + + # Create SVG document (A4) + dwg = svgwrite.Drawing(output_filename, size=(a4_width, a4_height), profile='tiny') + + # Add your content or elements to the SVG here + # For example, you can add a rectangle as a placeholder + asset_content_suffix=0 + for x in range(0,3): + for y in range(0,10): + print(f"Create Label: X={x}, Y={y} - {ASSET_CONTENT_PREFIX}{asset_content_suffix:03}") + # white bg for label + dwg.add( + dwg.rect( + insert=(f'{x*70}mm', f'{y*29.7}mm'), + size=('70mm', '29.7mm'), fill="white", stroke="none" + ) + ) + # asset number + asset_element = dwg.text( + str(f"{ASSET_CONTENT_PREFIX}{asset_content_suffix:03}"), + insert=(f'{x*70+29.7}mm', + f'{y*29.7+10}mm'), + font_size="37px", + font_family="Lato", + fill="black" + ) + dwg.add(asset_element) + # lost and found + lost_and_found_element = dwg.text(LOST_AND_FOUND_STRING, insert=( + f'{x*70+29.7}mm', + f'{y*29.7+15}mm'), + font_size="11.3px", + font_family="Lato", + fill="black" + ) + dwg.add(lost_and_found_element) + # freitextfeld + dwg.add( + dwg.rect( + insert=(f'{x*70+29.7+0.5}mm', f'{y*29.7+28.2}mm'), + size=('38.3mm', '0.2mm'), + fill="grey", + stroke="none" + ) + ) + + # create qr-code + asset_url = f"https://i.l3d.ch/a/{ASSET_CONTENT_PREFIX}{asset_content_suffix:03}" + qr_path = f"/tmp/homebox-{ASSET_CONTENT_PREFIX}{asset_content_suffix:03}.svg" + os.system(f'qrencode -t svg -l H -s 42 "{asset_url}" -o {qr_path}') + # import + qr_code_svg = svgwrite.image.Image( + f'{qr_path}', + insert=(f'{x*70}mm', + f'{y*29.7}mm'), + size=('29.7mm', '29.7mm') + ) + dwg.add(qr_code_svg) + asset_content_suffix+= 1 + + # Save the SVG document + dwg.save() + +if __name__ == "__main__": + create_a4_svg("output_a4.svg") diff --git a/homebox_label_template.svg b/homebox_label_template.svg deleted file mode 100644 index de4dab7..0000000 --- a/homebox_label_template.svg +++ /dev/null @@ -1,23606 +0,0 @@ - - - -Homebox Labels - Template000-00XFound it? https://l3d.ch/kontakt000-001Found it? https://l3d.ch/kontakt000-002Found it? https://l3d.ch/kontakt000-003Found it? https://l3d.ch/kontakt000-004Found it? https://l3d.ch/kontakt000-005Found it? https://l3d.ch/kontakt000-006Found it? https://l3d.ch/kontakt000-007Found it? https://l3d.ch/kontakt000-008Found it? https://l3d.ch/kontakt000-009Found it? https://l3d.ch/kontaktHomebox Labels - Template2023-01-12L3D <l3d@c3woc.de>CC-BY-SA 4.0