Can multiple Inkscapes be launched at same time via PHP pthreads?

Discussion about writing code for Inkscape.
wyatt121
Posts: 18
Joined: Wed Jan 03, 2018 8:15 am

Can multiple Inkscapes be launched at same time via PHP pthreads?

Postby wyatt121 » Wed Nov 13, 2019 4:51 am

Hi,

I use Inkscape via CLI with the PHP system command to create unique SVGs within a headless GUI. I use PHP to create a base SVG with unique text/variables (like a mail-merge), and then use Inkscape CLI verbs to complete actions and save out the "rendered" SVG.

Here is the issue. It is slow. 3 seconds per render. My entire database of data for the unique 30,000 SVGs to be created takes 24+ hours to render. Each SVG file creation requires an Inkscape to be launched and closed. This appears to only happen on 1 CPU core. I have 8 cores.

Can I launch 8 Inkscapes at the same time using pthreads? Or will Inkscape freak out?

Any help is much appreciated.


Regards,

Wyatt

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Can multiple Inkscapes be launched at same time via PHP pthreads?

Postby Moini » Wed Nov 13, 2019 8:50 am

Have you tried using the shell mode?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

wyatt121
Posts: 18
Joined: Wed Jan 03, 2018 8:15 am

Re: Can multiple Inkscapes be launched at same time via PHP pthreads?

Postby wyatt121 » Wed Nov 13, 2019 12:52 pm

Wow. I did not realize this existed. Very cool.

Hmmm. Curious. I have never done anything like this before.

If I run the following within PHP it will execute the shell and then just hang, as it waits for further instructions.

system("inkscape --shell");

How do I keep sending it verb commands in sequence from my PHP script?



Any help is very much appreciated.


Regards,

Wyatt

wyatt121
Posts: 18
Joined: Wed Jan 03, 2018 8:15 am

Re: Can multiple Inkscapes be launched at same time via PHP pthreads?

Postby wyatt121 » Thu Nov 14, 2019 4:30 am

Hmm. I don't think Inkscape --shell can accept verb commands, as the verb commands require a GUI.

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Can multiple Inkscapes be launched at same time via PHP pthreads?

Postby Moini » Thu Nov 14, 2019 10:51 am

Have you tried it? The man page doesn't say anything about the shell mode not working with gui, and indeed, it works.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)


Return to “Programming”