๐งต embroidery_tools
Comprehensive embroidery file format support for reading and writing stitch patterns
A robust library for handling embroidery files in various formats. Supports reading, writing, and manipulating stitch patterns for embroidery machines and design software. Built with precision and reliability for professional embroidery workflows.
โจ Features
๐ File Format Support
- PEC Format - Brother embroidery machine format (read/write)
- PES Format - Brother/Babylock embroidery format (v1 & v6)
- Cross-Platform - Works across different embroidery machine brands
- Version Detection - Automatic format version identification
๐ง Core Capabilities
- Pattern Reading - Extract stitch data, colors, and metadata
- Pattern Writing - Generate machine-compatible embroidery files
- Stitch Analysis - Examine pattern properties and statistics
- Color Management - Handle thread colors and palettes
๐ Data Processing
- Stitch Instructions - Jump, move, color change, and trim commands
- Coordinate Systems - Accurate positioning and scaling
- Thread Colors - RGB and palette-based color management
- Pattern Metadata - Design information and machine settings
๐ฆ Installation
Add to your Cargo.toml:
= { = true }
๐ Quick Start
Reading Embroidery Files
use *;
Writing Embroidery Files
use *;
๐ API Reference
Supported Formats
| Format | Read | Write | Versions | Description |
|---|---|---|---|---|
| PES | โ | โ | v1, v6 | Brother/Babylock embroidery format |
| PEC | โ | โ | - | Brother embroidery machine format |
Core Types
| Type | Description | Use Case |
|---|---|---|
EmbroideryPattern |
Complete pattern data | Pattern manipulation and storage |
Stitch |
Individual stitch point | Building stitch sequences |
Color |
Thread color information | Color palette management |
StitchCommand |
Stitch type/instruction | Machine command interpretation |
Pattern Operations
// Pattern analysis
let bounds = pattern.bounds;
let stitch_count = pattern.stitch_count;
let color_count = pattern.color_count;
// Pattern modification
pattern.scale; // Scale by factor
pattern.translate; // Move pattern
pattern.rotate; // Rotate pattern
pattern.optimize; // Remove redundant stitches
๐ฏ Use Cases
Professional Embroidery
- Design Software Integration - Import/export for embroidery design tools
- Production Workflow - Convert between different machine formats
- Quality Control - Analyze and validate embroidery patterns
- Archive Management - Organize and catalog design collections
Industrial Applications
- Automated Production - Generate patterns from CAD/vector data
- Format Conversion - Bridge different embroidery machine systems
- Pattern Analysis - Calculate thread usage and production time
- Custom Tooling - Build specialized embroidery workflows
Educational & Research
- Pattern Study - Analyze traditional and modern embroidery techniques
- Algorithm Development - Research optimal stitch path generation
- Format Documentation - Understand embroidery file structures
- Tool Development - Create new embroidery software solutions
๐ง Current Status & Roadmap
โ Implemented Features
- PEC Format - Full read/write support
- PES Format - Versions 1 and 6 support
- Basic Pattern Operations - Create, read, modify patterns
- Color Management - Handle thread colors and palettes
๐ง Planned Features
- Pattern Normalization - Automatic format compatibility fixes
- Additional Formats - DST, JEF, EXP, and other formats
- Advanced Editing - Cut, copy, paste, merge operations
- Optimization Algorithms - Minimize jumps and thread changes
- Preview Generation - Render patterns for display
โ ๏ธ Current Limitations
- Pattern editing capabilities are basic
- Some stitch instructions may need normalization before writing
- Limited to PES and PEC formats currently
- No built-in pattern optimization algorithms
๐ Technical Details
File Format Specifications
The library handles the binary formats according to official specifications:
- PES v1: Original Brother format with basic stitch data
- PES v6: Extended format with additional metadata and features
- PEC: Compressed Brother format optimized for machine storage
Coordinate Systems
- Internal coordinates use standard Cartesian system (mm)
- Automatic conversion to/from machine-specific coordinate systems
- Proper handling of origin points and scaling factors
Thread Color Handling
// RGB color specification
let red = rgb;
// Palette-based colors
let thread = palette_index;
// Named thread colors (if supported by format)
let rayon = thread;
๐ ๏ธ Integration Examples
With Image Processing
// Convert vector graphics to embroidery
use *;
Batch Processing
// Convert multiple files
use *;
use fs;