inkscape-applytransforms icon indicating copy to clipboard operation
inkscape-applytransforms copied to clipboard

Is there any way to get a verb for this so it can be run from the CLI?

Open alerque opened this issue 4 years ago • 11 comments

I would like to apply this as part of a build script. I like having a source SVG with all the original transforms for easy editing, but optimizing the output requires flattening all these things. I'd like to add this as a verb to my scripts. Is there a way to define a new verb in an extension?

alerque avatar Oct 08 '20 10:10 alerque

A quick glance at the documentation tells me this is likely possible, and sounds to me like a nice addition :+1:

Klowner avatar Oct 08 '20 12:10 Klowner

The id of the extension should be available as a verb. Calling inkscape -g --verb com.klowner.filter.applytransform --verb FileSave --verb FileClose --verb FileQuit test.svg works just fine for me to open a file, apply the transformation, save and close the file and to quit Inkscape.

Use inkscape --verb-list to get a list of all available verbs. This includes all extensions.

Please tell me if I'm missing the point.

I was using Inkscape 1.0.1.

ziegenberg avatar Jan 05 '21 10:01 ziegenberg

I guess this can be closed then?

ziegenberg avatar Jan 05 '21 20:01 ziegenberg

@ziegenberg yep! thank you again.

Klowner avatar Jan 05 '21 20:01 Klowner

While the trick with using the filter ID as a verb is appreciated, I don't think it goes far enough to warrant closing this issue.

This filter still assumes that a full GUI has been launched. I don't think it really needs it for anything and it does work with --verb com.klowner.filter.applytransform, but it does not work in batch mode with no GUI. There are certainly other Inkscape functions that require the GUI to be running to function, but I don't see why this would need to be one of them. I can't use this yet in automation sequences without providing a whole X environment to start Inkscape in.

Please consider adding a proper verb that can be used without a GUI and re-ope this issue to track the progress and notify others when someone contributes such a thing.

alerque avatar Jan 06 '21 17:01 alerque

apologies, @alerque. re-opened.

Klowner avatar Jan 06 '21 17:01 Klowner

Verbs require a GUI, says the current manual: https://inkscape.org/doc/inkscape-man.html

Note that the --verb command requires a GUI.

What you're probably looking for are actions. But I haven't found any documentation yet, that says that extensions can provide actions.

I will try that, as soon as I'm back at a PC.

ziegenberg avatar Jan 06 '21 18:01 ziegenberg

No worries. I wasn't aware of the fundamental difference between verbs / actions. Also it seems to be a bit of a moving target because everything used to be verbs (actions are new as I recall) and some of them required GUI and others didn't. If it turns out to be impossible I'll understand (Inkscape is not well setup for this) but if it is possible it would be appreciated.

alerque avatar Jan 06 '21 19:01 alerque

At the moment, Inkscape Script Extensions are one of three types:

  1. Input, providing translation from a file format to SVG
  2. Output, providing translation from SVG to a format
  3. Effect, taking in SVG, changing it, and then outputting SVG

Effects need a GUI.

Looking at the future architecture, the possibility of a headless Inkscape still seems to be something of the future. And looking at the current state of the roadmap, splitting backend / GUI frontend is also still in the works. They also want to develop a new plugin/extension system.

I'm afraid, this issue will remain open for quite a while.

ziegenberg avatar Jan 08 '21 18:01 ziegenberg

This might be fixed by https://wiki.inkscape.org/wiki/index.php?title=GSoC_2021_Verbs_to_Gio::Actions (https://gitlab.com/inkscape/inkscape/-/merge_requests/3328)

jtojnar avatar Jun 25 '21 00:06 jtojnar

I've tried to use verbs to remove transforms but it didn't worked : command : inkscape -g --verb com.klowner.filter.apply_transform --verb FileSave --verb FileClose --verb FileQuit test.svg

Everytime it closes the document before executing the transformation. It works when I remove --verb FileSave --verb FileClose --verb FileQuit, but it needs an user action this way.

Environment 1 : Windows 10 Inkscape 1.1.1 (3bf5ae0d25, 2021-09-20)

Environment 2 : Ubuntu 20.04 (WSL2) Inkscape 1.1.1 (1:1.1+202109281949+c3084ef5ed)

Is it still working by your side ?

EDIT

While waiting for better actions documentation for extensions, Here is a working command for Inkscape 1.1 : inkscape -g --verb "com.klowner.filter.apply_transform;FileSave;FileClose;FileQuit" test.svg

f-necas avatar Dec 07 '21 16:12 f-necas