Skip to main content

PyGrbl_Build 1.0.0

PyPI

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

  • Line-to-Line (l2l_gcode) — raster engraving from an image, with LaserGRBL fidelity.
  • Jarvis (jarvis_gcode) — 1-bit Jarvis-Judice-Ninke error diffusion followed by the same raster G-code engine. The dots are short powered raster segments, as in LaserGRBL.
  • 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")

Jarvis dithering (jarvis_gcode + JarvisProfile):

from pygrbl_build import JarvisProfile, jarvis_gcode, write_gcode

profile = JarvisProfile(width_mm=80.0, lines_per_mm=3.0, feed=3000, s_max=1000)
write_gcode(jarvis_gcode("photo.png", profile), "photo.nc")

Jarvis converts a color or gray image to a black-and-white dot pattern. Its profile exposes LaserGRBL's grayscale formula, channel weights, brightness, contrast and white clip, plus this library's bidirectional scan and optional overscan. It uses horizontal raster passes; vertical and diagonal directions are not implemented. The diffusion follows the coefficients and edge behavior of LaserGRBL's Jarvis implementation.

All image APIs (l2l_gcode, jarvis_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, JarvisProfile, jarvis_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. Publishing a GitHub release automatically publishes its distributions to PyPI after all required jobs succeed. Pushes and manual runs only create CI artifacts.

Before creating a release, update __version__ in src/pygrbl_build/__init__.py and use the matching version for the release tag (for example, v1.0.0). The workflow checks this match; it 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 1.0.0

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 1.0.0
File Size Uploaded
pygrbl_build-1.0.0.tar.gz 55.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pygrbl-build 1.0.0
File
pygrbl_build-1.0.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pygrbl_build-1.0.0-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-1.0.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pygrbl_build-1.0.0-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.28+ x86-64, Linux glibc 2.17+ x86-64 Details
pygrbl_build-1.0.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pygrbl_build-1.0.0-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-1.0.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pygrbl_build-1.0.0-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-1.0.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pygrbl_build-1.0.0-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: 863.3 kB

Release files / pygrbl_build-1.0.0.tar.gz

Download URL pygrbl_build-1.0.0.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff919642aa95140777411966a5da8ae9e421e4eb570e4466c36c942f3ac0b1c4
BLAKE2b-256 checksum
How to use checksums
4f107997385103bdf57b4d2068f336401476f22c0a83056134536a010e9a3d73
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp314-cp314-win_amd64.whl
Size 69.7 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
15dc78f296b9cbb6c7e0995a99e26d887cb62eb9a4f3bc9188d146f38162026c
BLAKE2b-256 checksum
How to use checksums
453c54e9eba9286c42a515d105305244097d9ac8f0788c5f46946fb7fb8ef947
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 93.1 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
60cc7c17408db6b2f88a70e71b19bc8d552ff7aaa9c7671ffb8a46371b728e37
BLAKE2b-256 checksum
How to use checksums
9a3ab4cee6994f9c5c663b935a845ee09aaf150be23152b7292cfe993a959cd9
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp313-cp313-win_amd64.whl
Size 68.9 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
0af7865f2672899d9fc641d3db7c4399f1b89543771cbe2e09a7203ca2dc4cae
BLAKE2b-256 checksum
How to use checksums
3e499bb881bd78083c45ecabd237ba8b1c929d6660d49ad907ffe5586316a2a4
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 93.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
48d5a13406079dea558c64bbc5f6757c53630b2c272bd04d731bdf7e6253ac7f
BLAKE2b-256 checksum
How to use checksums
de38fc51d8bcf29926aa98b99e752dc5d6b0dd7bdf87f6e2a2bf84966bd10db6
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp312-cp312-win_amd64.whl
Size 68.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
cbcdd79e0858d34084e3c015956dc9edf61a15107b2f1c296c38a6072e4bb65a
BLAKE2b-256 checksum
How to use checksums
7cac672a2fbd82069ab1fb63568a9e8a6466e3000cef155c0dd601641c12d3f1
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 92.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
79899ebbccd5551b6afb0f18e3d754aacb00a09ff72599657cec19148070a5cc
BLAKE2b-256 checksum
How to use checksums
0913b327ff57dbb5290e0e429eb6f6c49bf7d9f58a6c435d4c62b81a2b5de936
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp311-cp311-win_amd64.whl
Size 68.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
16583c76ebb5140596a869342bd5305a3e7c043d47c0ea8143c4a99aeb96d7cc
BLAKE2b-256 checksum
How to use checksums
3b04b1d5e14726a8030a67650a0b25e6874394644b2b26ec590bbbcacc4ed328
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 92.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9bc3ba4691e52bf0ea1e81dedc26e8ab9b7a1dcc97b8582aedb67cf4f27be543
BLAKE2b-256 checksum
How to use checksums
0e1f4611a7f98d47b05f5c151de58c2200e725c0d1c819a9c5a2e9151e719894
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp310-cp310-win_amd64.whl
Size 68.9 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
0fa1320690b29fe06e3b254ea79af3a2f6b8a228169842a8c9c21a7347239bb7
BLAKE2b-256 checksum
How to use checksums
6d3fe76627e7797e9d9d87f55e078b2f7f94bfb057bd5e207e7fa08fbb464460
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 22, 2026.

Transparency log

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

Download URL pygrbl_build-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 91.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
10dc0687f74b095b71734f6bd651eee64d07053414413a5d411ff146db951de4
BLAKE2b-256 checksum
How to use checksums
acc0e1047aab4cb6467b344ef6267e4842fae2412fdb6ba014c6baf31d8fceef
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 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 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