-
Notifications
You must be signed in to change notification settings - Fork 29
Home
- Official Documentation: README
- Support: Issues Tracker
Interesting usage examples to integrate in your own workflows: (please contribute!)
-
To export all "group" objects with an id or label that has been modified in inkscape, as long as the id and label don't match:
./svg-objects-export.py --xpath "//svg:g[@inkscape:label!=@id]" input.svg
-
To export all layers of a file in the area of the page first make sure all layers are visible (yes: all at the same time!), save and run:
./svg-objects-export.py --xpath "//svg:g[@inkscape:groupmode='layer']" --extra '--export-area-page --export-id-only' input.svg
-
To export all "root" groups in Inkscape, i.e. all groups with an id that starts with
g
that have no parent group with an id that starts withg
explanation::./svg-objects-export --xpath "//svg:g[re:test(@id, '^g', 'i')][ not(../../svg:g[re:test(@id, '^g', 'i')]) ]" -d groupWithNoParentGroup/ in.svg
The examples above rely on the inkscape extensions of SVG (The default inkscape format). They won't work with plain svg files (where, a.o. the concept of layers doesn't exist) or SVG files from other software, where you should rely only on valid SVG elements (see SVG specification), or use a specific id naming scheme.
For instance, if you rename all your layers id into "layer1", "layer2",.. "layer25", then you can export them using the following command:
svg-objects-export --pattern "^layer" --extra " --export-id-only" in.svg
Some users may get the following error when using the terminal of Mac OS: ImportError: No module named lxml" on Mac
It's fixed easily as per http://stackoverflow.com/questions/22674730/importerror-no-module-named-lxml-on-mac#22692262
sudo easy_install pip
sudo pip install lxml
(Yes, sudo
is required.) That takes a few seconds and BAM! It works (at least it did for dueddel).
Inkscape location may not be working out-of-the-box for you. If you get the message "Could not find inkscape command line executable, set --inkscape option accordingly." Simply provide the script with the explicite path to your inkscape installation, like below:
svg-objects-export.py --inkscape /Applications/Inkscape.app/Contents/Resources/bin/inkscape --type png in.svg
Using this script to export to SVG objects is currently limited by Inkscape poor support for this function. Basically: it works with a recent version of inkscape, but not all transformations (eg zoom, move) are applied correctly, leading to the exported objects being out of the bounding (display) box.
It is on the agenda of the Inkscape developpers (see bug report #1306662), there's nothing I can do to help.
- To turn the png into jpgs from command line there is imagemagick: (careful:
mogrify
command overwrites files without warning)mogrify -format jpg -quality 100 *.png