Can I merge a path into an envelope via an extension by way of the Inkscape command line?

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

Can I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby wyatt121 » Wed Jan 03, 2018 8:18 am

Hi,

Can I merge a path into an envelope via an extension by way of the Inkscape command line?

I'm trying to write a script to generate hundreds of unique graphic files each with different text within. This is typically done with mail merge, but I need to be able to merge the text into a bezier shape, and I need to do it within a php script.

I'm hoping to use this extension: https://github.com/shlomif/Bezier-Envelope-for-Inkscape https://www.youtube.com/watch?v=ldbdhVWaT20

Can I run this extension as a verb on the command line to squish my database text into a shape?

Any help is much appreciated.

Wyatt

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Can I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby brynn » Wed Jan 03, 2018 9:22 am

I can't answer your question directly. But just in case the command line reference can help: https://inkscape.org/en/doc/inkscape-man.html Hopefully someone else who knows the answer, will be along shortly.

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

Re: Can I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby Moini » Thu Jan 04, 2018 11:33 am

You should be able to.

Steps to do it:
1. print out all verbs, and (if on Linux) search for the correct option by adding a "| grep envelope" at the end (else you may need to browse the list, or search it in some other way):
inkscape --verb-list

I find it as 'de.gerrit_karius.envelope'.

2. when you have the verb, there is a .noprefs option listed. Use this in your script, if the other option doesn't work. Of course, you need to selected the two objects by their id first. And you need to have them in your file before that, or add them to it using another extension or an xml library... Text cannot be added directly via command line, it takes no arguments at all other than the ones indicated on the man page.

3. Hint: this will most probably still use the GUI, and will probably not work when you suppress it using the -z option.

4. Hint: for modifying multiple files, it's usually faster to use the interactive Inkscape command line.

5. The man page (or this: https://inkscape.org/doc/inkscape-man.html) has more info about the specifics.
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 I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby wyatt121 » Fri Jan 05, 2018 4:08 pm

Yippee Ki Yay! I have been working for this solution on/off for almost 6 months. Thank you so much for your response. Your response put all the pieces together for me.

Here is how it is done:

cp template.svg new.svg && inkscape new.svg --select=text187 --verb=SelectionCombine --verb=SelectionUnGroup --select=path3399 --verb=de.gerrit_karius.envelope.noprefs --select=path3399 --verb=EditDelete --verb=FileSave --verb=FileQuit

This command line copies the functionality displayed within this video:
https://www.youtube.com/watch?v=ldbdhVWaT20

This all works very well.

As you stated I canno't change/edit the text via the command line. This makes my process dirtier as I have to create a temporary "template.svg" in my php code for each database text record within my database before running the command above... but it works! I just wish there was a better way. Anyone have a better idea?

Thanks for all your help!

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

Re: Can I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby Moini » Sat Jan 06, 2018 10:28 am

There's an extension called 'generator', see http://wiki.inkscape.org/wiki/index.php ... #Generator for more info. Examples are given in the linked example file set. Not sure if that's useful though, as it basically does what you do with php, just in bash and with UI and via CSV file (so three times not what you need ;-) ).
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 I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby wyatt121 » Sun Jan 07, 2018 9:27 am

My process above required GUI to be launched because of the -z tag not supporting inkscape verbs. This was extremely annoying and forced me to run my scripts through a GUI. This slows down the process considerably. I stumbled upon a workaround that works great! Instead of using a full GUI, I launch a dummy GUI within the terminal. It is about 4x faster.

Here is more info:
https://corpocrat.com/2008/08/19/how-to ... ux-server/

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

Re: Can I merge a path into an envelope via an extension by way of the Inkscape command line?

Postby Moini » Sun Jan 07, 2018 1:25 pm

Yes, I just had a very dim flash of recognition - I think at one time, someone else mentioned that as a solution for running Inkscape on a headless server... Definitely need to remember xfvb next time!
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”