Export many pdfs from command line (30% faster)

Bug #889402 reported by thebravoman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
New
Wishlist
Unassigned

Bug Description

Hi.

I need to export a number of svg documents to pdfs using inkscape from the command line. Actual command execution is done by a shell script. I would like to propose a new feature=

The problem is that in order to export 3 documents I had to invoke three commands:
>inkscape -f 1.svg -A 1.pdf
>inkscape -f 2.svg -A 2.pdf
>inkscape -f 3.svg -A 3.pdf

I have changed main.cpp file so that currently this could be done as:
>inkscape -f 1.svg 2.svg 3.svg -A unused.pdf
The result documents are 1.svg.pdf, 2.svg.pdf, 3.svg.pdf and the unused.pdf is actually "unused".

Testing the two approaches showed good performance improvements. On exporting 40000 documents with "inkscape -f 1.svg 2.svg -A unused.pdf" rather then "inkscape -f 1.svg -A 1.pdf && inkspace -f 2.svg -A 2.pdf" I got an average of 30% faster execution.

Change is done in:
void sp_process_file_list(GSList *fl) {
           ...
           if (sp_export_pdf) {
  gchar pdfext[6] = {".pdf\0"};
  gchar *new_export_pdf = g_strconcat(g_strdup(filename), &pdfext, NULL);
         do_export_ps_pdf(doc, new_export_pdf, "application/pdf");
  g_free(new_export_pdf);
            }
            ...
}

Would it be possible to take a look on my approach and probably include this, or a similiar feature in inkscape? I could prepare a patch if you like the idea.

Tags: cli exporting pdf
su_v (suv-lp)
tags: added: cli exporting pdf
Changed in inkscape:
importance: Undecided → Wishlist
Revision history for this message
su_v (suv-lp) wrote :

1) Please attach a proper patch ('diff -u' or 'bzr diff' preferred) and provide information against which version (Inkscape 0.48.2, Inkscape trunk) the patch is meant for.

2) The syntax you propose seems highly ambiguous to me: users would expect that Inkscape can export multiple SVG documents merged into a single PDF fiel (which it can't).

3) Why don't you use the existing shell mode to export multiple files without launching a new process for every export?

example to export 10 files in one process using bash:

   for i in {1..10}; do echo " -f file-$i.svg -A file-$i.pdf"; done | inkscape --shell

(Note: when using this to process a huge number of files, there is a small memory leak occuring that needs to be fixed, see bug #722229.)

Revision history for this message
thebravoman (thebravoman) wrote :

1) If we could agree on options list I could prepare a patch.

2) What about adding a new option like "--filetype={pdf, ps, img}", where a user invokes inkscape with a number of files and they are all converted to the specified filetype. Like:
> inkscape -f 1.svg 2.svg 3.svg --filetype=pdf

3) Short answers is a test I have made (which I have improved further from last time)

1. executing a new process
>inkscape -f 1.svg -A 1.pdf
>inkscape -f 2.svg -A 2.pdf
>inkscape -f 3.svg -A 3.pdf
results in average time for document export of 0.71 seconds per document

2. executing the modified code with
>inkscape -f 1.svg 2.svg 3.svg -A unused.pdf
results in average time for document export of 0.25 seconds per document

3. executing with the interactive shell
> for i in {1..10}; do echo " -f file-$i.svg -A file-$i.pdf"; done | inkscape --shell
results in average time for document export of 0.41 seconds per document

Revision history for this message
Johan Engelen (johanengelen) wrote :

this is similar to another bug report about being able to export to other fileformats besides pdf/eps/.. through the cmdline. I'm sure you can find out which bugreport and link it here suv! ;-) thanks

Revision history for this message
Johan Engelen (johanengelen) wrote :

(what i meant is that the "--filetype=xxx" thingie should look what output extension belongs to the xxx fileextension and use that one :))

Revision history for this message
su_v (suv-lp) wrote :

Johan Engelen wrote
> similar to another bug report about being able to export
> to other fileformats besides pdf/eps/.. through the cmdline.

@Johan - I fail to find such a specific request for the command line:

a) Did you refer to the RFE for the GUI to support saving in multiple formats at the same time?
 Bug #182937 “Multi-save in my chosen formats whenever I hit ctrl-s”
 <https://bugs.launchpad.net/inkscape/+bug/182937>

I don't see that one related to the task described in this report (which aims to optimize performance when using Inkscape as mass file convertor on the command line).
The current '--shell' mode already allows to reuse the same inkscape process for several operations (from the command line), but doesn't support usage of verbs for example, nor are verbs scriptable (they take no arguments).

b) or did you refer to one of these?
 Bug #503784 “export to dxf via command line”
 <https://bugs.launchpad.net/inkscape/+bug/503784>
 Bug #361237 “Provide scriptable method of saving files”
 <https://bugs.launchpad.net/inkscape/+bug/361237>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.