I'm looking for a way to run inkscape in batch mode (without GUI) to apply the "resize to content" GUI action to an SVG from the command line. I'm in 1.3 (so verbs are not an option) on Linux. Is there a sequence of actions to do that? Obviously, these is because I need to apply this to 100's of SVG.

  • Hi. Do you mean like Edit > Select all, then Edit > Resize Page to Selection? I've no idea if you could use these from the command line though. Maybe someone over at Unix & Linux stack exchange/Stack Overflow would know.
    – Billy Kerr
    Commented Jan 7 at 13:27
  • No need for select all. The document is larger than the content. It's a conversion to SVG of a PDF that was created from a PPTX by someone who used "print as pdf" instead of "save as pdf". So there are two white bands. One on top and one below of each slide. If you open the svg of a single slide in gui mode and just resize to content, the document returns to the original 16/9 slide dimensions. No need to select anything. Just save. Commented Jan 7 at 13:42
  • Yeah, but if you want to use another sequence of actions within Inkscape, then you need to make a selection first before applying resize page to selection (this is not the same as resize to content available within the document properties dialog). "Resize page to selection" requires that a selection be made. Unfortunately I can't tell you if it's even possible to use these from the command line, and coding is generally off-topic here, which is why I suggest you might want to reach out to the other stack exchange communities.
    – Billy Kerr
    Commented Jan 7 at 14:29
  • 1
    @BillyKerr 'Resize Page to Selection' resizes "to the current selection or the drawing if there is no selection". See my screenshot below. Also, there is the select-all action, so if it did need a selection, then you could simply use --actions="...;select-all:all;page-fit-to-selection".
    – Xrott
    Commented Jan 7 at 14:57
  • 1
    @Xrott - I stand corrected. That's good to know.
    – Billy Kerr
    Commented Jan 7 at 15:04

2 Answers 2


To manipulate a document before saving from the command-line, you use the --actions="..." option with a list of action-ids separated by semicolons (;).

To find out the id of an operation from inside Inkscape, you can use the command-palette. However, first you need to open the preferences, go to 'Interface → Command Palette' and enable the 'Show command line argument names' setting. You'll have to restart Inkscape for it to take effect.

Now press ? to open the command-palette (depending on your keyboard layout, you may also need to hold Shift) and search for resize for example to get the app.page-fit-to-selection action (the app. prefix can be omitted). You can even click on the id to copy it to the clipboard.

Screenshot of Inkscape's command-palette with 'Resize Page to Selection' operation highlighted

All in all, your command should look something like this:

inkscape --actions="page-fit-to-selection" -o "./output.svg" "./input.svg"

You can loop through your SVG documents and convert them as follows:

On Unix-like system:

for f in *.svg; do inkscape -D -o  resized_${f} $f; done

On Windows (using Powershell):

gci *.svg | % { inkscape -D -o ("resized_" + $_.Name) $_.FullName }


If you have a directory with the following content:


The result after running the command above will be:

  • Thanks, that seems to work too. However, the page dimensions are preserved. In your browser, only the document is displayed. However in inkscape GUI, the page is unchanged. This is different from the accepted solution. Still upvoted. Commented Jan 7 at 17:52
  • @AlainPannetier: The command above works as expected. Not sure what issues you're encountering.
    – s.ouchene
    Commented Jan 7 at 19:15
  • @AlainPannetier: Could you share a screenshot? I can't reproduce the issue you're encountering.
    – s.ouchene
    Commented Jan 8 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.