• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Python
  • Created over 11 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Export multiple SVG elements to other formats (png, pdf, ps, eps, svg), selecting them based on their ID with regular expressions, or XPath expression.

svg-objects-export

Export multiple SVG elements to other formats (png, pdf, ps, eps, svg), selecting them based on their ID with regular expressions, or XPath expression.

Useful for designing multiple icons in single file, sprite sheets, or multi-page documents with Inkscape (or other SVG editor). Easily generate low-resolution and high-resolution renders of some of the objects included in various SVG files... and more.

usage

svg-objects-export.py [-h] [-p PATTERN] [options] infiles

arguments

positional arguments:

infiles               SVG file(s) to export objects from, wildcards are
                      supported

optional arguments:

-h, --help            show this help message and exit
-p PATTERN, --pattern PATTERN
                      pattern (regular expression) to identify which objects
                      to export or exclude from export (depending on
                      --exclude). Default pattern matches most ID generated
                      automatically by Inkscape (in exclude mode).
-x XPath EXPRESSION, --xpath XPath EXPRESSION
                      XPath expression to identify which objects to export 
                      or exclude from export (depending on --exclude). This
                      option is not considered if a pattern is provided (see
                      --patern).
-e, --exclude         use pattern or expression to determine which objects 
                      to exclude from export, rather than include
-d DESTDIR, --destdir DESTDIR
                      directory where images are exported to. Trailing slash
                      is needed (backslash for windows), default is working
                      directory.
-s, --silent          do not print information to command line. Silent mode
                      does not overwrite existing files by default, combine
                      with --force if needed.
-f, --force           overwrite existing files. Default is to warn and
                      prompt user unless --silent is active.
-P PREFIX, --prefix PREFIX
                      prefix the generated file names with given PREFIX.
                      "FILE" in the prefix is replaced with the svg file
                      name.
-i INKSCAPE, --inkscape INKSCAPE
                      path to inkscape command line executable
-t {png,ps,eps,pdf,plain-svg}, --type {png,ps,eps,pdf,plain-svg}
                      export type (and suffix). png by default. See Inkscape
                      --help for supported formats (png, ps, eps, pdf,
                      plain-svg).
-X Inkscape_Export_Options, --extra Inkscape_Export_Options
                      Extra options passed through (litterally) to inkscape
                      for export. See Inkscape --help for more.
-D, --debug           Generates (very) verbose output.

requirements

This program requires Inkscape 0.48+ and Python 2.7+

default behaviour

The program exports by default all objects with an ID that has not been generated automatically by Inkscape.

If you provide a custom pattern (-p) or xpath expression (-x), then exclude (-e) is by default turned off, that is: your custom pattern or expression is used to define wich objects are included unless you specify -e.

examples

svg-objects-export.py --pattern '^export' in.svg

exports all objects with an ID starting with 'export' from in.svg to PNG files in the current directory.

 svg-objects-export.py --exclude --xpath '//svg:g | //svg:rect' in.svg

exports all objects that are no SVG group or rectangle, from in.svg to PNG files in current working directory. Namespaces available are: svg, inkscape, sodipodi, xlink, re (for regular expressions). See http://lxml.de for more on xpath in this program.

svg-objects-export.py --pattern '^(obj1|obj4)$' --prefix 'FILE_' in1.svg in2.svg

exports objects with IDs 'obj1' and 'obj4', from both in1 and in2 files, to PNG files named in1_obj1.png, in1_obj4.png, in2_obj1.png and in2_obj4.png.

svg-objects-export.py --silent --force --type eps --destdir vector/  ~/*.svg ~/tmp/*.svg

exports all objects with an ID that does not resemble Inkscape default IDs, from any SVG file in user's home and tmp directories, to vector/ directory as EPS files, with no information displayed and overwritting existing files

svg-objects-export.py --exclude --pattern '[0-9]' --extra '--export-dpi 900' in.svg

exports all objects with an ID containing no digit, from in.svg file, as PNG images with a resolution for rasterization of 900 dpi. As Inkscape uses 90 by default, this results in 10-times bigger images.

Additional examples: https://github.com/berteh/svg-objects-export/wiki

license

This software is release under the terms of FRESH-JUICE-WARE LICENSE:

Berteh wrote this file. You can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can offer me a nice fresh juice.

The author of this work hereby waives all claim of copyright (economic and moral) in this work and immediately places it in the public domain; it may be used, distorted or destroyed in any manner whatsoever without further attribution or notice to the creator. Constructive feedback is always welcome nevertheless.

More Repositories

1

ScribusGenerator

Create beautiful documents with data. Open source pdf (and Scribus) template and mail-merge alternative.
Python
250
star
2

mindslide

View Freeplane mindmap as an HTML presentation (aka freemind to powerpoint slideshow)
HTML
60
star
3

BandInMuseScore

Accompaniment generator for MuseScore, something like Band-In-A-Box, auto-magically powered by MMA Musical Midi Accompaniment.
QML
32
star
4

synfig-import-labels

Generate Kinetic Typography (artistic subtitles) in Synfig, 2D OpenSource Animation Studio, or simply import your timings and labels (/subtitles).
Python
19
star
5

musescore-chordsToNotes

The harmony playback feature is now available in MuseScore 3 (https://github.com/musescore/MuseScore/pull/5129#issuecomment-601717806) , development of this plugin is thus stopped, thanks for you feedback and positive comments in the past. This plugin for MuseScore 2.0 will expand chords annotations into a few notes in voice 4, directly playable by MuseScore.
QML
17
star
6

synfig-projects

personal Synfig projects
Perl
3
star
7

gnome-pdf-tool

Automatically exported from code.google.com/p/gnome-pdf-tool
Python
2
star
8

find2tree

generate jstree json data from a directory listing
HTML
1
star
9

pico_leaflet

Adds Leaflet maps to blog posts with Address or Coordinates meta and creates a map with all these blog posts.
JavaScript
1
star
10

print-weight-barcodes

Loose goods Tare automated for Point-of-Sale - print a (barcode) label with weight from (serial) scale
Python
1
star
11

magic-table

Automatically exported from code.google.com/p/magic-table
HTML
1
star