diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-06-21 18:43:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-21 18:43:18 +0200 |
| commit | 4cef6be086ac23bbe018caa4f85bcf2f0a684e34 (patch) | |
| tree | 65a154c65b9e25c12d18924f4ffe10ea683d6e64 /lib/extensions/stitch_plan_preview.py | |
| parent | 4e143db33a547571c90ad2736e9c0bbd53759801 (diff) | |
Fix realistic stitch plan preview for inkscape versions 1.3 and 1.3.1 (#3004)
Co-authored-by: CapellanCitizen
Diffstat (limited to 'lib/extensions/stitch_plan_preview.py')
| -rw-r--r-- | lib/extensions/stitch_plan_preview.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/extensions/stitch_plan_preview.py b/lib/extensions/stitch_plan_preview.py index 983435bb..464e4200 100644 --- a/lib/extensions/stitch_plan_preview.py +++ b/lib/extensions/stitch_plan_preview.py @@ -5,6 +5,7 @@ import sys from base64 import b64encode +from re import findall from tempfile import TemporaryDirectory from typing import Optional, Tuple @@ -133,10 +134,14 @@ class StitchPlanPreview(InkstitchExtension): "export-do" # Inkscape docs say this should be implicit at the end, but it doesn't seem to be. ])) + # Extract numbers from returned string. It can include other information such as warnings about the usage of AppImages + out = findall(r"(?m)^-?\d+\.?\d*$", out) + # The query commands return positions in px, so we need to convert to uu. px_to_uu = svg.unittouu("1px") + # Parse the returned coordinates out. - x, y, width, height = map(lambda x: px_to_uu*float(x), out.split()) + x, y, width, height = map(lambda x: px_to_uu*float(x), out) # Embed the rasterized stitch plan into the SVG, and replace the original stitch plan with open(temp_png_path, "rb") as f: |
