Celeb Glow
news | March 03, 2026

How to crop SVG?

How do you crop all empty space from an SVG file, specifically from the command line?

I have several SVG files formatted to the standard A2 letter document size, and I need to bulk crop them down so their view box is the same as the minimum bounding box for their contents.

I can do this in Inkscape using the "Resize Page to Selection" option, but I don't see any way to access this function from the command-line.

2 Answers

Try:

inkscape --batch-process \ --verb "EditSelectAll;FitCanvasToSelection;FileSave;FileQuit" \ filename.svg

Under Mac OS the following command line worked:

inkscape -g --verb="FitCanvasToDrawing;FileSave;FileQuit" filename.svg

Note that if I provide three different --verb option (which is recommended by the other answers), it didn't work (probably, only the last verb was executed).

1

It looks like the "Resize Page to Selection" option is available via command line! Check it out here:

inkscape --verb=FitCanvasToDrawing --verb=FileSave --verb=FileQuit *.svg

(Use FileClose for older versions of Inkscape.)

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy