Generate punchcard die-cutting files from PCX and PNG image charts.
This uttility generates SVG files, usable in most diecutting machines, for punchcards for 12-stitch and 24-stitch punch card machines, from PCX and PNG images. A large library of PCX and PNG image charts are available from https://github.com/kevinlearnscoding/Machine-Knitters-Companion
- 🎯 Generate SVG cut files for punchcards from PNG or PCX images
- 🧵 Supports 12-stitch and 24-stitch card widths
- 🔁 Layout modes:
auto,motif, andrepeat - 📏 Vertical repeats for longer pattern runs
- 🧪 Batch processing from shell globs and stdin
- ⚙️ Threshold and inversion controls for image-to-punch mapping
Install python and Pillow dependency
python3 -m pip install PillowDetermine what kind of punch card machine your using (12-stitch or 24-stich), how many repeats across the width of the card you want, and how many vertical repeats you want the card. Format your input as:
python3 punchcard-generator.py design.png 24 motif 6Output file:
design.punch.svg
For a full beginner walkthrough, see the QuickStart guide: QUICKSTART.md
- Python 3.8+
- Pillow (
pip install Pillow)
python3 punchcard-generator.py INPUTpython3 punchcard-generator.py INPUT [STITCHES] [LAYOUT] [REPEAT_HEIGHT]Examples:
python3 punchcard-generator.py motif.pcx 24 motif 6
python3 punchcard-generator.py tile.png 12 repeat 4
python3 punchcard-generator.py design.png 24 auto 1Shell glob batch:
python3 punchcard-generator.py *.pcx 24 motif 2 -d /path/to/output/dirstdin batch:
find . -name "*.pcx" | python3 punchcard-generator.py --stitches 24 --layout motif --repeat-height 2-o OUTPUT_PATHoutput directory-d RECREATE_DIRECTORIESrecreate input directory structure in destination--stitches {12,24}card width (default24)--layout {auto,motif,repeat}layout mode (defaultauto)--repeat-height Nvertical repeats (default1)--threshold 0-255image threshold (default255)--invertinvert punched and non-punched spaces on the card--hole-ratio 0-1hole size ratio (default0.55)
motif: centers a design within the card widthrepeat: tiles design across width (design width must divide by card width)auto: picksmotiforrepeatbased on width compatibility
Ideas, bug reports, and PRs are welcome.
If you tweak behavior, updating both docs keeps things smooth for users:
README.mdQUICKSTART.md
Built for makers, tinkerers, and knitters who love automation.