From ab8c87928b39e7874c09a75b2f9badd3a46719b2 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 24 Jun 2022 17:11:52 +0200 Subject: Update pyembroidery (#1683) Embroidery formats (read) .hus: Husqvarna Embroidery Format .zhs: Zeng Hsing Embroidery Format Color formats (read & write) .col : Color format. .edr : Color format. .inf : Color format. Stitch formats (read & write) .pmv : Brother Stitch Format. Image (write) .png : Portable Network Graphic (line art) G-Code The export file format is not .txt anymore but .gcode Bug fixes --- lib/output.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib/output.py') diff --git a/lib/output.py b/lib/output.py index e330354d..65e6f64d 100644 --- a/lib/output.py +++ b/lib/output.py @@ -4,8 +4,8 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import sys -import inkex +import inkex import pyembroidery from .commands import global_command @@ -33,8 +33,8 @@ def _string_to_floats(string): return [float(num) for num in floats] -def get_origin(svg, xxx_todo_changeme): - (minx, miny, maxx, maxy) = xxx_todo_changeme +def get_origin(svg, bounding_box): + (minx, miny, maxx, maxy) = bounding_box origin_command = global_command(svg, "origin") if origin_command: @@ -52,7 +52,12 @@ def jump_to_stop_point(pattern, svg): def write_embroidery_file(file_path, stitch_plan, svg, settings={}): + # convert from pixels to millimeters + # also multiply by 10 to get tenths of a millimeter as required by pyembroidery + scale = 10 / PIXELS_PER_MM + origin = get_origin(svg, stitch_plan.bounding_box) + origin = origin * scale pattern = pyembroidery.EmbPattern() stitch = Stitch(0, 0) @@ -68,10 +73,6 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}): pattern.add_stitch_absolute(pyembroidery.END, stitch.x, stitch.y) - # convert from pixels to millimeters - # also multiply by 10 to get tenths of a millimeter as required by pyembroidery - scale = 10 / PIXELS_PER_MM - settings.update({ # correct for the origin "translate": -origin, @@ -92,6 +93,9 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}): settings['max_stitch'] = float('inf') settings['max_jump'] = float('inf') settings['explicit_trim'] = False + elif file_path.endswith('.png'): + settings['linewidth'] = 1 + settings['background'] = 'white' try: pyembroidery.write(pattern, file_path, settings) -- cgit v1.2.3