Gathering detailed insights and metrics for lbrn2-to-svg
Gathering detailed insights and metrics for lbrn2-to-svg
Gathering detailed insights and metrics for lbrn2-to-svg
Gathering detailed insights and metrics for lbrn2-to-svg
npm install lbrn2-to-svg
Typescript
Module System
Node Version
NPM Version
TypeScript (84.64%)
HTML (13.59%)
JavaScript (1.77%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
27 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jun 24, 2025
Latest Version
0.5.3
Package Id
lbrn2-to-svg@0.5.3
Unpacked Size
101.39 kB
Size
23.33 kB
File Count
12
NPM Version
10.9.2
Node Version
23.10.0
Published on
May 16, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
lbrn2-to-svg
)A TypeScript library and command-line interface (CLI) to parse LightBurn LBRN2 project files and convert their 2D vector shapes, images, and text outlines to Scalable Vector Graphics (SVG) format.
This project aims to provide a robust tool for developers needing to work with LBRN2 files programmatically or convert them for use in other applications. It is designed to be compatible with various JavaScript/TypeScript environments, including Node.js, Deno, Bun, and modern web browsers (for the library functionality).
Rect
, Ellipse
, Path
(including Lines and Bezier curves), Group
, Bitmap
, Text
(via BackupPath).<XForm>
).<CutSetting>
elements for vector shapes.Shapes/Elements:
<Shape Type="Rect">
(including corner radius Cr
)<Shape Type="Ellipse">
(converts to <circle>
if Rx
equals Ry
)<Shape Type="Path">
<VertList>
(vertex coordinates and control points c0x, c0y, c1x, c1y
)<PrimList>
(primitives: L
for Line, B
for Bezier)<Shape Type="Group">
(with nested shapes and transform composition)<Shape Type="Bitmap">
W
(width), H
(height), and Data
(Base64 encoded image data).<image>
element with xlink:href
set to the data URL.Gamma
, Contrast
, etc.) are parsed but not used in the SVG output.<Shape Type="Text">
Text
shape has HasBackupPath="1"
and contains a <BackupPath>
child of Type="Path"
, the parser automatically replaces the Text
shape with this Path
shape.Text
shapes without a usable BackupPath
are currently skipped/ignored for rendering.Transformations: <XForm>
matrix for each shape and group.
Cut Settings: Uses CutIndex
to link vector shapes (Rect
, Ellipse
, Path
, Group
) to <CutSetting>
for stroke color. Default colors are used if a color is not explicitly defined in the CutSetting
. Note: Style settings are not applied to <image>
elements converted from Bitmap
shapes.
Coordinate System: Correctly handles LightBurn's Y-up coordinate system and transforms it to SVG's Y-down system within the calculated viewBox
.
Text
elements to SVG <text>
elements (which would involve font handling, layout, etc.) is not supported. Text is only rendered if a vector BackupPath
is available.CutSetting
. Other laser parameters are ignored.PrimList
primitives (if any beyond Line and Bezier) are not fully tested or supported.1# Using npm 2npm install lbrn2-to-svg 3 4# Using yarn 5yarn add lbrn2-to-svg 6 7# Using bun 8bun add lbrn2-to-svg
After installation, you can use the CLI tool:
1npx lbrn2-to-svg <input.lbrn2> <output.svg>
Or, if installed globally or as a project dependency with scripts:
1lbrn2-to-svg path/to/your/file.lbrn2 path/to/output/file.svg
Example:
1lbrn2-to-svg project.lbrn2 project.svg 2# SVG written to project.svg
You can use the library in your TypeScript or JavaScript (ESM) projects:
1import { parseLbrn2, lbrn2ToSvg, type LightBurnProjectFile } from 'lbrn2-to-svg'; 2import fs from 'fs/promises'; 3 4async function convertFile(inputPath: string, outputPath: string) { 5 try { 6 const lbrn2Xml: string = await fs.readFile(inputPath, 'utf-8'); 7 const project: LightBurnProjectFile = parseLbrn2(lbrn2Xml); 8 const svgString: string = lbrn2ToSvg(project); 9 await fs.writeFile(outputPath, svgString, 'utf-8'); 10 console.log(`SVG successfully written to ${outputPath}`); 11 } catch (error) { 12 console.error('Conversion failed:', error); 13 } 14}
The core parsing and conversion functions (parseLbrn2
, lbrn2ToSvg
) are pure and do not rely on Node.js-specific APIs, making them suitable for browser environments if you provide the LBRN2 XML string.
1git clone https://github.com/jlucaso1/lbrn2-to-svg.git 2cd lbrn2-to-svg
1bun install
To compile TypeScript to JavaScript (outputs to dist
directory):
1bun run build
A tsconfig.json
is included for build configuration.
Run tests using Bun:
1bun test
Tests use .lbrn2
and .svg
artifact files located in tests/artifacts/
.
A utility script is provided to minimize the size of .lbrn2
test artifacts by removing non-essential XML elements and attributes. This helps keep test files focused on the geometric data being tested.
To run the minimizer on files in tests/artifacts/
:
1bun run scripts/minimize_lbrn2_artifacts.ts
Contributions are welcome! Please feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.
Ensure to update tests as appropriate.
This project is licensed under the MIT License - see the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.