Friday, 15 July 2011

bash - How to process 20k SVG files with Inkscape CLI mode ? (align and merge objects) -



bash - How to process 20k SVG files with Inkscape CLI mode ? (align and merge objects) -

i'm generating ~20 000 files based on template. files contains 2 objects:

a chinese character (hanzi) ; its pronunciation (pinyin).

this part working nicely, to:

align hanzi left ; align pinyin right merge hanzi , pinyin this imply first convert <svg:text> <svg:path>

with next options:

class="lang-bash prettyprint-override">inkscape -f file.svg \ --select=hanzi --verb=alignhorizontalleft --verb=editdeselect \ --select=pinyin --verb=alignhorizontalright --verb=editdeselect \ --select=hanzi --select=pinyin \ --verb=alignverticalcenter --verb=selectionunion \ --verb=filesave --verb=filequit

the throttle open/close inkscape each file.

n.b.: i'm using inkscape 0.48.4 r9939 (jan 22 2014)

question is there way process several files in 1 inkscape instance ? what alternative align* verbs not available in inkscape --verbs-list ? reference original source code

i not know inkscape @ all, think issue is slow - though not explicitly. anyway, maybe seek gnu parallel this:

parallel -j 8 ./process {} ::: *.svg

that maintain 8 jobs running in parallel till 20,000 files processed. {} short-hand filename, , list of filenames given after :::. if there may files command line, can feed them in on stdin:

find . -name "*.svg" | parallel -j 8 ./process {}

then wrap inkscape command in script called process , create executable (using chmod +x process) , create take single parameter - i.e. filename.

i guess worth seek anyway - utilize little copied folder of samples till confident gnu parallel.

bash optimization svg inkscape

No comments:

Post a Comment