Skip to content

Call inkscape --shell with batches of files for faster processing #52

Description

@MayeulC

I am not sure how doable it is, but I would prefer the package to assemble a list of all svg files and call inkscape only once in batchmode, to convert all the files in one invocation. This is typically much faster than one invocation per file.

The batch interface changed a bit recently. This is what I do to convert pdf to svg with the current (1.2.2) version:

(for file in *.pdf; do echo "file-open:$file; export-filename:$(echo $file | sed s/.pdf/.svg/); export-do;";done ) | inkscape --shell

(yes, I could have bash variable text substitution, but I think calling sed is more portable?).

export-latex can be used as well.

This could roughly results in the following sequence:

$ inkscape --shell
file-open:file1.svg; export-filename:file1.pdf; export-latex; export-do;
file-open:file2.svg; export-filename:file2.pdf; export-latex:false; export-do;
file-open:file3.svg; export-filename:file3.pdf; export-latex:true; export-do;

For reference, I used to do the following pdf->svg conversion in a Makefile with an older version of inkscape:

# Yes, the pattern makes no sense, it's just to tell make that these are built all at once
# https://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file
$(PDF_SVG_FILES:%-svg-converted-to.pdf=%-svg-converted-to.pd%): $(SVG_FILES)
        # converting svg files with inkscape...
        (for file in $?; do echo $$file --export-pdf=$$(echo $$file | sed s/.svg/-svg-converted-to.pdf/);done ) | inkscape --shell

But I'm not sure it's worth it to support older versions with a new feature.

If it's not possible to do so (if files need to be passed to the pdf engine right away), I suggest adding an option to allow skipping graph generation on the first pass. Ideally, placeholders of the right size should be created, but I am not sure this is possible either.

I don't mind compiling once more, personally (currently, I run a first --draft-mode compilation anyway, plus ~3 others), especially if it leads to much faster compile times overall.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions