When linking to PNG raster graphics from Inkscape SVG documents, it seems that Inkscape always insists on writing the absolute path to the PNG graphic to the file. This has many disadvantages (which, obviously, can be mitigated by manually editing the SVG file in a text editor after every save, but that cannot be the idea behind a graphical editor such as Inkscape):
- I cannot move the directory with my graphics without breaking the SVG.
- I cannot store the directory with my graphics on a portable memory to work on it from various computers, as the portable device will get assigned different drive letters.
- I cannot edit my graphics from different operating systems, as they may mount the partition that stores the SVG files and the PNG graphics on different mount points.
- I cannot provide the directory with my graphics to colleagues on a network share from where they can copy it, because the paths will not match up.
- The files cannot be directly committed to and shared via version control systems such as SVN or Git for the same reason. At the very least, every time someone commits the changed file, lines that contain full paths will be pointlessly registered as changes by the VCS.
- With files frequently stored in the user's home directory, this even introduces a privacy risk by giving away the user name of the creator (in work settings, often the real name), or other information about the creator's file system.
Even now, that Inkscape seems to use relative paths and just add the full path in an extra attribute (
sodipodi:absref), several of the issues above are still around (in particular, the privacy concern is unchanged, and so is the VCS issue).
Note that I do not want to embed the PNG data in the Inkscape documents for various reasons, two of which are:
- The graphics may change later on, and it is more flexible to have the PNG image as a separate PNG file where I can edit it (and it will thus be updated automatically when opening Inkscape again), instead of embedding the PNG data in the SVG, still saving it as an extra file (so I can edit the PNG image later on) and every time I change the PNG; embedding the new version again in Inkscape, manually adapting its position and size to match that of the previous version and then removing the previous version.
- Various of the PNG images (think logos or other corporate-identity-related graphics) are used in a multitude of SVG documents, so it would simply be a waste of space to embed one such image into every single SVG document, rather than storing it just once and referring to that original PNG graphic from each SVG document. (And of course, the effort from the previous item multiplies with every SVG document I use a given modified raster graphic in.)
As a workaround, I have thought of writing a script that has to be run over SVG files after saving, either with XSLT, or with some conventional language that can load SVGs. Possibly, this could also be set up as a pre-commit-hook for the aforementioned version control systems. However, doing so seems sufficiently tedious to me, so I only want to go to those lengths if there really is no other way.
Is there a way to force Inkscape to write only the relative paths to linked images into the SVG file? (Also for the most recently used bitmap export path, if possible.)