Inkscape and SVG

So, being the non-artist that I am (and the rest of the ACM chapter here), I edit SVGs in vim. This makes me cringe whenever I see SVGs that have been saved with Inkscape. Inkscape likes to put weird namespaced attributes and such around the code basically duplicating whatever the standard attributes are. So the first thing I do when I get an Inkscape-generated SVG is strip the useless stuff out. Completely. I don’t know what this does for Inkscape, but seeing as it’s still standard SVG, everything should work just as intended.

Another gripe I have is that it puts everything down two levels of dereferencing. Shapes use a gradient, which is in the defs, that’s okay. But then that gradient references another gradient for its stops. Why this separation? I’ve also seen objects defined that aren’t referenced at all (I imagine gradients that were made then ditched later).

Inkscape also likes to export attributes that aren’t necessary. If the fill is none, the fill opacity, color, and rules mean nothing, so don’t bother writing it out. The id tags on objects are just numbers, making use of search necessary. Everything is put into style=”foo:bar;” instead of foo=”bar” format. I’m sure this makes parsing slightly faster, but it’s irrelevant since how many extra attributes are set (not to mention Inkscape-specific ones). It’s harder to read and edit since syntax highlighting tends to be “string blob” and not “string of key/value pairs”.

I’d like to see Inkscape have an “Export to SVG” menu option so that a nice, minimal SVG is output. Without the Inkscape-specific extensions, without the unneeded attributes, etc.

Maybe it’s just me, but anyone else do their drawings in a text editor (including, but not limited to, SVG, MetaPost, pic, TikZ)?

6 Responses to “Inkscape and SVG”

  1. Ian Weller says:

    File -> Save… save as a Plain SVG instead of an Inkscape SVG.

  2. finalzone says:

    “I’d like to see Inkscape have an “Export to SVG” menu option so that a nice, minimal SVG is output. Without the Inkscape-specific extensions, without the unneeded attributes, etc.”

    Inkscape allows saving file in plain SVG.

  3. Alex says:

    In the file type dropdown in the Save As dialog, there is a “Plain SVG” option. Does that also have Inkscape cruft?

  4. Ben Boeckel says:

    Ah, maybe I should clarify: “I’d like to see Inkscape have an “Export to SVG” menu option used more often“.

    As for checking it myself, I do not actually have Inkscape installed. I just see lots of SVGs that I’d like to modify for use that have the Inkscape attributes scattered around.

  5. nicu says:

    We don’t save as Plain SVG that often since the extra information (the bloat) is useful if people are supposed to edit the image later in Inkscape.