abey79 / vpype

The Swiss-Army-knife command-line tool for plotter vector graphics.
https://vpype.readthedocs.io/
MIT License
687 stars 61 forks source link

`multipage` command to split an SVG into smaller, slightly overlapping SVGs #149

Open LoicGoulefert opened 3 years ago

LoicGoulefert commented 3 years ago

Usage

vpype read input.svg multipage -i a3 -o a4

Command options:

Description

multipage splits a file into smaller, slightly overlapping files. Say input file format is a3, outputs formats would be 2 slightly smaller than a4 files (if -o a4 is used), or 4 slightly smaller than a5 files (if -o a5 is used), and so on. multipage should always consider input files as portrait oriented. As the output files are intended to be drawn on the same piece of paper, multipage rotates by 180° the output files making up the bottom half of the input file. To avoid having a visible seam between the output files, multipage creates a "seam-zone", and randomizes the crop on the lines within this zone. Lines fully contained in the "seam-zone" should not be cropped.

abey79 commented 3 years ago

Some late night feedback in no particular order:

LoicGoulefert commented 3 years ago

Agreed with all of your remarks.

  • multipage should always consider input files as portrait oriented.

    Why is that? It could take whatever current page size/bounds aspect ratio and decide on the best output aspect ratio, depending on the splitting.

I was thinking that most plotters draw on a landscape oriented page, so having an a3 file should result in 2 a4, landscape oriented files, instead of two 42 x 14.85cm files, but that was poorly worded !

  • (At this stage, I'm getting a little scared of this feature to be honest 😄)

Same here, especially if this involves touching the write command as you mentionned.

LoicGoulefert commented 3 years ago

Specification evolution

Examples

vpype read a3_file.svg   # a3 file with 1 layers
    multipage -o a4         # we now have 2x1 layers, and page format is a4
    write --page 1 --page 2 output.svg

yields 2 a4 format files output_1.svg, output_2.svg. Each output file has 1 layer, labelled "1".

vpype read a2_file.svg   # a2 file with 3 layers
    multipage -o a4         # we now have 3x4 layers, and page format is a4
    write --page 1..3 --page 4..6 --page 7..9 --page 10..12 output.svg

yields 4 a4 format files output_1.svg, output_2.svg, output_3.svg and output_4.svg. Each output file has 3 layers, labelled "1", "2", and "3", which are consistent with the original a2_file.svg layers.

New features involved

multipage options:

Layer range argument: support the a..b range syntax. 1..3 would select layers 1, 2 and 3.

--page option for write: write a file with the selected layers at the current file size. If this command is used multiple times, an appendix is added to the output file argument. [...] write --page 1..3 output.svg creates a single file output.svg. [...] write --page 1..3 --page 4..6 output.svg creates 2 files, output_1.svg and output_2.svg.