Selectively Export layers from Command Line Interface

Bug #170901 reported by Lolmeduz on 2005-09-08
This bug affects 10 people
Affects Status Importance Assigned to Milestone

Bug Description

Intended users : people using inkscape for
presentations may want to progressively show different
aspect of their drawing (for instance in a flow chart,
the different steps) or highlight differently certain
parts (when describing the central nervous system, I
widh to focus sequentially on various parts). a first
solution is to create many svg files. a better solution
(inspired by metapost) is to use the same SVG file and
to export selectively the layers.

solution : the best would be to be able to export from
the command line different layers. a simple script
would then create the different files (I like to export
in pdf using epstopdf) which could be imported to the
presentation (Impress, or I use Latex with the Beamer

example :
inkscape filename.svg --select-layer=layer1
-alpha-layer=.2 -select-layer=layer2 -alpha-layer=1

would export the layers layer1 and layer2 with resp.
alpha values of .2 and 1 to filename.png

Thanks for the excellent work


Horkana-users (horkana-users) wrote :


might want to implement it in a more generic way

rather than simply breaking apart at each layer you would
break apart at each <group> or <tag> of a given depth.
like how openoffice HTML export includes an option to create
a new page at each <h1> or other tag, could be very powerful.

Hystrix (hystrix-) on 2007-12-19
Changed in inkscape:
importance: Undecided → Wishlist
Changed in inkscape:
status: New → Confirmed
Nick Piper (nick-launchpad) wrote :

This would be really useful - I was surprised not to find it.

I wonder when --export-id was added, and if that could be a starting point.

tags: added: cli
su_v (suv-lp) on 2011-04-19
tags: added: layers
removed: import-export

I quote it, it could be surely useful e.g. to make buttons starting from a common layout.

Matteo Cypriani (mcy) wrote :

Just for the record, the Dia's layer export option is very practical. From dia(1):

       -L LAYER,LAYER,... --show-layers=LAYER,LAYER,...
           Only include specified layers when exporting.
           Layers can be specified either as a layer name, the
           layer number or a numeric range X-Y of layers.
           --show-layers=background,2-5 shows the layer named
           background and layers 2-5, --show-layers=2- shows
           layers 2 and up.

su_v (suv-lp) on 2012-07-22
tags: added: bitmap
jazzynico (jazzynico) wrote :

It's possible to export a layer with the command line, you just need to know the layer's ID:

# inkscape -j -i layerid -e exported-layer.png document.svg

OK, you must open the XML editor first and find the layer in the tree, but the ID should be something like layer1, layer2, etc.

Thanks JazzyNico, it is a start. It seems it is not possible to export two (or N-1 layers) "-j -i layer1 -i layer" only exports layer2. Exporting more than one layer at a time (ideally any arbitrary combination of layers) is needed to make animations for presentations by progressively showing/hiding layers.

jazzynico (jazzynico) wrote :

@Manuel - Exporting several ids is a known issue tracked in Bug #171476 "Allow several -i (--export-id=ID) options"

su_v (suv-lp) wrote :

> Exporting several ids is a known issue (…)

Doesn't the shell mode serve this purpose?

OK, let's mark it as a duplicate then. But it would be extra nice if the man page and the --help output mentioned that the ID of layers is "layerN" where N=1,2,... is the layer number.

jazzynico (jazzynico) wrote :

> Doesn't the shell mode serve this purpose?

Yes, it's a bit heavier but it works:

1. Create a commands.txt file with you commands:
-j -i layer1 -e layer1.png document.svg
-j -i layer2 -e layer2.png document.svg
2. Run Inkscape in Shell mode:
# inkscape --shell < commands.txt

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers