Skip to main content

PyGrbl_Build 0.4.1

PyPI

A collection of algorithms to generate G-code for GRBL diode lasers from different sources, plus tooling around the G-code itself. Four generators today:

  • Line-to-Line (l2l_gcode) — raster engraving from an image, with LaserGRBL fidelity.
  • SVG vector (svg_gcode) — vector tracing from an SVG (paths, basic shapes, groups, transforms), a faithful port of LaserGRBL's SVG import. Pure Python, no extra dependency.
  • Image vector (img2vector_gcode) — outline tracing from a raster image (LaserGRBL's "Vectorize!"): the image is reduced to black/white, Potrace traces its outlines as closed contours, and each curve is emitted as G2/G3 arcs. Pure Python, Pillow only. Outlines only today (no interior filling yet).
  • Image to SVG (img2svg) — the same Potrace trace as img2vector_gcode, but the contours are written to a standard vector SVG instead of G-code. Inner contours become holes (fill-rule evenodd), so you get the filled black silhouette potrace.exe produces. Pure Python, Pillow only.

Plus G-code bounds & framing (get_bounding_box + generate_framing_gcode): a fast C parser for the bounding box of any G-code (file or in-memory) and a framing pass that traces it, so the operator can confirm placement before engraving.

Part of the pygrbl family, a set of libraries to manage GRBL. Companion to pygrbl_streamer and pygrbl_server

Speed

This is the whole point. A full 300 mm @ 10 lines/mm raster job — nearly 4.7 million lines of G-code — comes out in ~0.34 s. LaserGRBL can take around 2 minutes to produce the same job: that's roughly a 350× speedup, and byte-for-byte the same output.

Install

pip install pygrbl-build

The only requirements are Pillow and a C compiler. Pillow is the single Python dependency (image loading and resizing); the C compiler is needed at install time because the raster engine ships as a C extension. Nothing else — no numpy, no runtime toolchain.

Usage

Each algorithm pairs a *_gcode generator with its own *Profile config, so adding one never touches the others.

Raster Line-to-Line (l2l_gcode + L2LProfile):

from pygrbl_build import L2LProfile, l2l_gcode, write_gcode

profile = L2LProfile(width_mm=300.0, lines_per_mm=10.0, feed=3000, s_max=100)
write_gcode(l2l_gcode("shield.png", profile), "shield.nc")

All image APIs (l2l_gcode, img2vector_gcode, and img2svg) also accept encoded image bytes, bytearray, or an already loaded PIL.Image.Image. This allows in-memory services to work without writing a temporary image:

from PIL import Image

with open("shield.png", "rb") as source:
    from_bytes = l2l_gcode(source.read(), profile)

from_pillow = l2l_gcode(Image.open("shield.png"), profile)

SVG vector (svg_gcode + SvgProfile):

from pygrbl_build import SvgProfile, svg_gcode, write_gcode

profile = SvgProfile(feed=1000, s_max=255)
write_gcode(svg_gcode("logo.svg", profile), "logo.nc")

svg_gcode accepts a path as before, or the SVG XML directly as str, bytes, or bytearray.

SvgProfile's defaults reproduce LaserGRBL's own SVG-import defaults, so the output matches the desktop app for the same drawing. text and image elements are skipped — convert text to paths in your editor first.

Image vector (img2vector_gcode + Img2VectorProfile):

from pygrbl_build import Img2VectorProfile, img2vector_gcode, write_gcode

profile = Img2VectorProfile(width_mm=80.0, quality=10.0, feed=1000, s_max=1000)
write_gcode(img2vector_gcode("logo.png", profile), "logo.nc")

img2vector_gcode is a faithful port of LaserGRBL's "Vectorize!": the image is reduced to black/white (resize, grayscale, white-clip, optional threshold), Potrace traces its outlines, and each cubic Bezier is approximated by biarcs and emitted as G2/G3 arcs (with a G1 fallback). width_mm sets the physical width and quality the tracing resolution in pixels/mm. The Img2VectorProfile defaults follow Potrace's classic settings (smooth curves, optimization on); set alphamax=0.0 and opticurve=False to mimic LaserGRBL's own out-of-the-box UI defaults.

Image to SVG (img2svg + Img2SvgProfile):

from pygrbl_build import Img2SvgProfile, img2svg

profile = Img2SvgProfile(width_mm=80.0, quality=10.0)
svg = img2svg("logo.png", profile)
with open("logo.svg", "w", encoding="utf-8") as f:
    f.write(svg)

img2svg runs the same trace as img2vector_gcode (resize, grayscale, white-clip, optional threshold, then Potrace outlines), but skips the biarc/G-code stages and writes the contours as a single filled <path>. It returns the complete SVG document as a string (not a G-code iterator, so use your own open()). The Img2SvgProfile carries only the tracing and binarization knobs — no feed, power or laser-mode fields. viewBox is in pixels (width_mm*quality) while width/height carry the physical size in mm, and the image keeps its natural top-down orientation (no Y-flip, unlike the G-code path).

G-code bounds & framing (get_bounding_box + generate_framing_gcode):

from pygrbl_build import get_bounding_box, generate_framing_gcode

# From a file path (opened and streamed in C — handles 500MB+ in seconds)...
min_x, max_x, min_y, max_y = get_bounding_box("job.nc")

# ...or straight from G-code already in memory, no file needed:
gcode = "\n".join(svg_gcode("logo.svg", SvgProfile()))
min_x, max_x, min_y, max_y = get_bounding_box(gcode)          # str
min_x, max_x, min_y, max_y = get_bounding_box(gcode.encode()) # or bytes

frame = generate_framing_gcode(min_x, max_x, min_y, max_y, power=10.0, speed=1000)

get_bounding_box is the original gcode-bounds C parser folded in. It accepts a file path (str/Path, opened and streamed in C) or the G-code content directly (bytes, or a multi-line str), so it never has to exist on disk — the Python wrapper picks the route. Only X/Y are considered; rapid moves to the origin (G0 with X0/Y0) are skipped so home moves don't expand the box. generate_framing_gcode returns the perimeter trace as a list of lines (power is 0-100, speed in mm/min).

write_gcode writes the path verbatim, so you choose the extension (.nc, .gcode, .g, ...). It's just a convenience: every *_gcode generator is a lazy iterator of lines, so anything beyond writing a plain file (compression, network shipping, streaming to the machine) is the upper layer's job — consume the iterator with whatever sink you need.

Public API: L2LProfile, l2l_gcode, SvgProfile, svg_gcode, Img2VectorProfile, img2vector_gcode, Img2SvgProfile, img2svg, get_bounding_box, generate_framing_gcode, write_gcode. See the docstrings.

Publishing to PyPI

.github/workflows/build.yml builds and tests on pushes to main (excluding documentation-only changes), on published GitHub releases, and on manual runs. Only Actions → Build distributions → Run workflow → main publishes to PyPI, after all required jobs succeed. Pushes and releases only create CI artifacts.

Before publishing a new version, update __version__ in src/pygrbl_build/__init__.py. The workflow does not increment versions or skip existing PyPI files.

One-time setup: create the pypi-release GitHub environment and add a GitHub Trusted Publisher in the PyPI project's Publishing settings with:

  • Owner: offerrall
  • Repository: pygrbl_build
  • Workflow filename: build.yml
  • Environment: pypi-release

Authentication uses OIDC (id-token: write); no PyPI API token secret is needed. See PyPI's Trusted Publisher setup.

Release files for pygrbl-build 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygrbl-build 0.4.1
File Size Uploaded
pygrbl_build-0.4.1.tar.gz 51.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pygrbl-build 0.4.1
File
pygrbl_build-0.4.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pygrbl_build-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
pygrbl_build-0.4.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pygrbl_build-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
pygrbl_build-0.4.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pygrbl_build-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
pygrbl_build-0.4.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pygrbl_build-0.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
pygrbl_build-0.4.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pygrbl_build-0.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 788.8 kB

Release files / pygrbl_build-0.4.1.tar.gz

Download URL pygrbl_build-0.4.1.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff6630ed3b177030c722c69483dc610be679a37501e9c9ab262e7882483cb0a8
BLAKE2b-256 checksum
How to use checksums
60b8c3b124d44d352df1fa0e96b54733e7f579428b067963c3c9fbf1244d0a71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp314-cp314-win_amd64.whl

Download URL pygrbl_build-0.4.1-cp314-cp314-win_amd64.whl
Size 65.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
dbe7754f83f509a4ce335d797b12a9d747b61a60363aa151f71bfecd0cd650b0
BLAKE2b-256 checksum
How to use checksums
f3394955c3efc1457e564c9d0ab02cc0619a5ca57ec48bd0dfbc540103b795f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pygrbl_build-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 83.0 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ce8f863de5db79c7983af1d8968613da5050e05e94e966e546bb70ad908ff850
BLAKE2b-256 checksum
How to use checksums
962bb58361f0c8f59bee233472869427b8b4d1f06731c6658f80afe8e8d98aa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp313-cp313-win_amd64.whl

Download URL pygrbl_build-0.4.1-cp313-cp313-win_amd64.whl
Size 64.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
7fb5bf7b2befd288f518817b04e2c9b913e4146cf5844c72d860cb2a0fa86375
BLAKE2b-256 checksum
How to use checksums
539412335912e9c3215ea15f1dd1a9eb14ceba8117f460ed94cbb81fcced543e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pygrbl_build-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 83.0 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e58a0434819d94a16a63d1046782df196367fe63cb046fb36c7abb8a3546594f
BLAKE2b-256 checksum
How to use checksums
baed4c3e7243d896a9a9f958ee708b5f09a23cf05c9e1e1fd13c8110f44d9718
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp312-cp312-win_amd64.whl

Download URL pygrbl_build-0.4.1-cp312-cp312-win_amd64.whl
Size 64.8 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
3b3d86042c54286a4da0019d681399f172174a197d41d1d0b4bbc76d807d27e2
BLAKE2b-256 checksum
How to use checksums
0feaface551111b892d5d7a5e85dce9f676381751d872765a93c84e8403f2d9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pygrbl_build-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 82.9 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4a318a0679e0ab3f5026911a5983bcf9f1f4582d727bf1c711d00c2c750b8c89
BLAKE2b-256 checksum
How to use checksums
a04c507c003164fea8aa8d3e462a0308005d888a391243f8eb0721f607344a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp311-cp311-win_amd64.whl

Download URL pygrbl_build-0.4.1-cp311-cp311-win_amd64.whl
Size 64.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
39a15fd4aaba7c45464758dc416299f1aa6a27a5d0a5ddc1ff9afe8e3d4b6085
BLAKE2b-256 checksum
How to use checksums
8f7ded3c973f3693383f70a95054182c1ae149fd76895cea94cd6f080e669c00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pygrbl_build-0.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 82.2 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cad447279b73dc57f0ab1a8159735783563825af32251025f0cc97ae2105b78c
BLAKE2b-256 checksum
How to use checksums
76a1ec2a453187d74c0712211355cba025fc846152b5087f05f5cd2ac6c4a5b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp310-cp310-win_amd64.whl

Download URL pygrbl_build-0.4.1-cp310-cp310-win_amd64.whl
Size 64.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
fa5456f6741fd7a611eb25833b63503246e657c121bb967c6d4b61e8c9d1cc9a
BLAKE2b-256 checksum
How to use checksums
db4c179d4e11f0150caa9e3640a321d8e119658de36b9c561dd371e28395cce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pygrbl_build-0.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pygrbl_build-0.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 81.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9b7d431348299aa118006dd79660cab101b7e599ce0e33703511faff2bbd072f
BLAKE2b-256 checksum
How to use checksums
633d781ada451905afe046af981d56feccfd18ffa917ac3e25cffdf7febf45b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.0

11 release files

This release

0.4.1 This release

11 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page