Comment 1 for bug 1722844

johannes (fghgfh832) wrote :

Many, if not all, verbs seem to require GUI. The basic command line interface is a bit restricted and I agree that it would be very useful to have more options, e.g. when one wants to do batch conversion of a large number of images.

But what you want to do, should be possible.

Using command line, you can save as (plain) SVG using
--export-plain-svg=NEWFILENAME

You can fit the canvas of the resulting image by using
--export-area-drawing

BUT this does not work when exporting as SVG. It does work when exporting as EPS or PNG.

So as a workaround, you can export to EPS, then convert back to SVG:

inkscape --without-gui --export-eps=TEMPFILENAME.eps --export-area-drawing OLDFILENAME.svg

inkscape --without-gui --export-plain-svg=NEWFILENAME.svg TEMPFILENAME.eps

More complex operations *might* be possible via Python scripting but I have no experience on that.