rustitch
A Rust library for parsing PES embroidery files and rendering stitch data to images.
Part of the stitch-peek-rs project.
Usage
Add rustitch to your Cargo.toml:
[]
= "0.1"
Generate a thumbnail
let pes_data = read?;
let png_bytes = thumbnail?;
write?;
Parse and inspect a design
use ;
let data = read?;
let design = parse?;
println!;
println!;
println!;
let stitch_count = design.commands.iter
.filter
.count;
println!;
Resolve and render manually
use pes;
let data = read?;
let design = parse?;
let resolved = resolve?;
println!;
println!;
let png_bytes = render_thumbnail?;
write?;
Supported formats
PES (Brother PE-Design) embroidery files, versions 1 through 10. The PEC section containing stitch data is consistent across versions.
How it works
- Parse the PES binary header to locate the PEC section
- Decode the PEC stitch byte stream (7-bit and 12-bit encoded relative movements, jumps, trims, color changes)
- Resolve relative movements into absolute coordinate segments grouped by thread color, using the 65-color Brother PEC palette
- Render anti-aliased line segments with tiny-skia, scaled to fit the requested size
- Encode as PNG with proper alpha handling
License
MIT