rustitch
A Rust library for parsing embroidery files and rendering stitch data to images.
Supported formats: PES, DST, EXP, JEF, VP3
Part of the stitch-peek-rs project.
Usage
Add rustitch to your Cargo.toml:
[]
= "0.2"
Generate a thumbnail
// PES files (backward-compatible API)
let pes_data = read?;
let png_bytes = thumbnail?;
write?;
// Any supported format
let dst_data = read?;
let png_bytes = thumbnail_format?;
write?;
Parse and inspect a PES 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?;
Format detection
use ;
use Path;
// Detect from file extension
let fmt = detect_from_extension;
assert_eq!;
// Detect from file content (magic bytes)
let data = read?;
let fmt = detect_from_bytes;
assert_eq!;
Supported formats
| Format | Manufacturer | Colors | Notes |
|---|---|---|---|
| PES | Brother PE-Design | Embedded (PEC palette) | Versions 1-10 |
| DST | Tajima | Default palette | 3-byte bit-packed records |
| EXP | Melco/Bernina | Default palette | Simple 2-byte encoding |
| JEF | Janome | Embedded (Janome palette) | Structured header with color table |
| VP3 | Pfaff/Viking | Embedded (RGB) | Hierarchical format with per-section colors |
Formats without embedded color info (DST, EXP) use a default palette of 12 high-contrast colors, cycling on each color change.
How it works
- Detect the file format from magic bytes or extension
- Parse the format-specific binary encoding into a common
StitchCommandstream (stitch, jump, trim, color change, end) - Resolve relative movements into absolute coordinate segments grouped by thread color
- Render anti-aliased line segments with tiny-skia, scaled to fit the requested size
- Encode as PNG with proper alpha handling
License
MIT