Diastasis separates complex SVG artwork into production-ready layers.
- Three separation modes:
Overlaid Complexity: overlap-aware layering.Flat Complexity: strict area-exclusive separation.Color Separation: one plate per ink color (screen-print / vinyl / risograph), with tolerance-based merging to minimize plate count.
minimum_layersalgorithm (default): portfolio of coloring strategies, iterated refinement, and exact search on small graphs — the summary states when the layer count is provably the minimum possible.- Headless CLI (
python cli.py) with batch folder processing. - Per-layer file export: one registered SVG per layer (shared canvas and crop marks) for production stacking.
- High-fidelity export: untransformed rects/circles/ellipses/polygons keep their original markup; original path data preserved whenever valid.
- Broad SVG input coverage: transforms (incl. groups),
viewBoxcoordinate spaces, compound paths with holes (nonzero/evenodd),polyline,defs/usereferences, curved segments sampled accurately. - Quality presets:
Accurate,Balanced,Fast.
- Complexity estimator:
- shape count, candidate pairs, graph density, ETA.
- Batch mode:
- process all
.svgfiles in a folder with current settings.
- process all
- Export profiles:
Illustrator-safe,Print,Web.
- Visible-boundary clipping (
Clip Shapes To Visible Boundaries). - Performance mode for weaker systems / huge files.
- Flat controls:
- touch policy (
No edge/corner touching,Allow corner touching) - overlap priority (
Source order,Largest first,Smallest first)
- touch policy (
- Layer analytics in summary:
- overlap/conflict count
- tiny fragment count
- per-layer area share
git clone https://github.com/tsevis/Diastasis.git
cd Diastasis
pip install -e ".[gui]" # library + CLI + GUI dependenciesThis installs the diastasis command. For headless use (servers, CI),
pip install -e . is enough — the GUI extras are only needed for gui.py.
python gui.pyor:
./run_gui.sh- Click
Select SVG. - Choose
Quality PresetandExport Profile. - Click
Estimate Complexity(recommended for heavy files). - Choose mode (
Overlaid ComplexityorFlat Complexity). - Set optional controls:
Clip Shapes To Visible BoundariesPerformance Mode
- Click
Process. - Export with:
Save Layers As...Save Clipped 1-Layer As...
# One file -> output/artwork_layered.svg (+ summary with optimality proof)
diastasis artwork.svg -o output/
# Strict flat separation, one registered SVG file per layer
diastasis artwork.svg -o output/ --mode flat --separate-files
# Whole folder with print settings
diastasis --batch input_folder/ -o output/ --profile Print
# Color separation: one plate per ink, merge near colors, unify to a single ink
diastasis artwork.svg -o output/ --mode color --color-tolerance 12 --unify-plate-colors
# Clean cut/print plates: one path per ink with seams between tiles removed
diastasis artwork.svg -o output/ --mode color --merge-fragments
# Non-overlapping clipped mosaic as one flat SVG layer
diastasis artwork.svg -o output/ --clip --single-clipped-layer
# Check how heavy a file is before processing
diastasis artwork.svg --estimatepython cli.py ... works too when running from a source checkout. Run
diastasis --help for all options (algorithm, touch policy, overlap
priority, clipping, stroke-aware footprints, performance mode, recoloring).
- Configure settings as desired (mode, preset, profile, clipping, etc.).
- Click
Batch Process Folder. - Choose input folder (SVG files).
- Choose output folder.
Each file is processed with the same active settings.
Illustrator-safe: balanced precision, crop marks included.Print: higher path precision, crop marks included.Web: lower precision, no crop marks.
from diastasis import run_diastasis, save_layers_to_files
shapes, coloring, summary, w, h = run_diastasis(
"input.svg",
mode="flat",
flat_algorithm="minimum_layers",
flat_touch_policy="any_touch",
flat_priority_order="source",
clip_visible_boundaries=True,
performance_mode=False,
)
save_layers_to_files(
shapes,
coloring,
"output",
"job",
w,
h,
preserve_original_colors=True,
export_profile="Illustrator-safe",
)MIT