Crop SVG from command line
Bug #1722844 reported by
fabrice salvaire
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Wishlist
|
Patrick Storz |
Bug Description
Some peoples are looking for a command line tools to crop SVG (e.g. for web)
I found this command
inkscape --verb=
But it requires a GUI
--without-gui crashes Inkscape
Would be nice to have an option, to sanitize the SVG, fit the canvas and add an optional margin.
I guess the api is here, it just misses some codes.
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
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 plain-svg= NEWFILENAME
--export-
You can fit the canvas of the resulting image by using area-drawing
--export-
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=TEMPFILENAM E.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.