Inkscape: embedding or linking?

Inkscape: embedding or linking?

This article explains the difference between embedding and linking in Inkscape and advices when to use each of them.

The question popped up again, this time — on inkscapeforum.com. Since 0.48 whenever you drop a bitmap image into an Inkscape's document (or use File > Import...), you get exactly this dialog:

Never mind the techie lingo is the window's caption. The dialog actually explains what happens, but it never hurts to elaborate.

Which is which?

Embedding is a bit of technical jargon. It means placing files inside other files. When you choose embedding, a copy of an image file you dropped into Inkscape's document will be saved inside this document. So if you choose "embed", Inkscape will later load this image as part of SVG document, just like a Bezier path or circle or text.

If you are into details, because SVG is essentially a text based file format, that image will be encoded with base64 — a kind of textual representation of non-textual data. Here is what the relevant bit of the SVG file will look like:

What embedding looks like from the inside

Linking means that Inkscape saves information about location of this image inside SVG document. So every time you open a document that links to an image file, Inkscape will try to find this image in the location that was saved inside SVG document, load it and show it to you. Again, here is the relevant bit from the SVG document:

What linking looks like from the inside

If you want more technical details on linking, you can read the related part of SVG specification.

How to tell the difference between an embedded image and an linked image if they just load and look OK? If you never paid much attention to the status bar, it's about time you started doing so.

When you select an embedded image, the status bar message says exactly that:

Embedded

However, when the image is linked, the status bar shows full path to an image and its name instead:

Linked

So, embedding or linking?

In terms of default Inkscape's behavior, it's all down to workflows really.

If you only use Inkscape to provide non-SVG data to your client (sliced design of a website, PDF with a postcard, et cetera) and you never move files around, you can freely use linking.

If you are used to sharing your project files via Dropbox or SparkleShare, or just carrying stuff between desktop and laptop, you probably want embedding.

Why does it matter? One important thing to understand here is that Inkscape always saves absolute paths by default when you choose linking. This means that full path to an image will be saved, from top system folder down to the folder where you actually keep the image.

(This is also the reason why in case of previously unsaved SVG documents Inkscape puts copypasted images, as well as bitmap copies of vectors to user's home folder — so that they are locatable.)

So if you copy your SVG file to a different computer, you will also have to (at least partly) replicate the folders hierarchy, otherwise Inkscape won't be able to locate your image automatically. Alternatively you will have to manually edit path to the image and then do it once again every time you copy your SVG to a different system. Needless to say, this can be quite exhausting.

Embedding also prevents images from being accidentally changed by a different application, while with linking Inkscape will honestly open whatever is referenced in the SVG document, even if the image was inadvertently changed. On the other hand, being able to change images from outside can be desirable, especially if the image in question is an exported flattened composition of a multilayered GIMP project that you keep changing.

Sounds like it'd be nice to be able to un-embed an image or embed a previously linked image. It is possible? Yes.

Swapping embedding and linking

In the current version of Inkscape, 0.48, you can embed and/or extract selected images via these two commands from Extensions > Images menu:

Embedding and extracting menu items

If you choose embedding, Inkscape will show another dialog to ask if you want embedding just currently selected linked images or all linked images.

If you choose extracting, Inkscape will ask you where to store your images. If extraction was successful, embedded images will automagically become linked.

There's one more important matter to discuss.

Relinking

Up till now we discussed default Inkscape's behaviour — things you see without getting your hands really dirty. Now roll up your sleeves: it's time to learn about relinking.

Relinking means telling Inkscape to use an image from a different folder or, if you wish, even a different image.

Let's say you added an image to your document by linking to it. Right-click on the image and choose Image Properties menu item:

Image Properties Menu Item

What you get is a dialog that apart from everything else shows current path to an image:

Image Properties Dialog

If you want just simple relative paths, when bitmap images are in the same folder as SVG, simply remove current path and leave only name of file, in this case — 1.png:

Relative path

Once again, in that case Inkscape will always look for 1.png in the same folder where the SVG file is. Thus the SVG document becomes safely shareable.

You can also use "../1.png", if the file is in an upper folder, or "bitmaps/1.png", if the file is in "bitmaps" folder that is inside current SVG document's folder (i.e. nested folder). Of course, in this case should you want to share your project, you'd also have to share upper folder or nested folder respectively.

Bottom line

Embedding is safest way to share your SVG file or move it from computer to computer at the cost of file size.

Default linking with absolute paths is fine as long as you keep your work on one computer and never move folders.

Custom relative links help sharing project data or moving it around at cost of having to manually change paths and allowing images to be inadvertently changed.

Is there a better way to handle images?

Surely someone would think of making this easier for users? Indeed, it's exactly what happened. Last year a group of students from Centrale Lyon led by Steren Giannini worked on improving the existing tools for embedding, linking and relinking. You can read more about the project here. With luck improvements will be part of v0.49 thus obsoleting half of this article, so it's a call for patience. Which, purely coincidentally, is a virtue,

Courtesy first-aid kit image by: Yuriy Apostol

Was it useful? There's more:

9 Comments

Leave a comment
  1. Hi Alexandre - thx a lot, great article! :)
    Nit-picking as always… I’ll add just a small comment:

    prokoudine wrote:

    Extracting won’t make an embedded image automagically linked, it will merely save it to a folder. Then you can re-add these images if you need to.

    If the extraction worked without failure, the extracted image is automatically linked into the SVG document (i.e. the URL of the <image> object now refers to the image on the hard-drive). There is no need to manually re-add the image.

    (tested with Inkscape 0.47 and current 0.48.1)

  2. @su-v Many thanks for correction as usual :) Fixed in text.

  3. Hi Alexander,
    Knowing the differences between embed and link is great for advanced users I think. Good article.

    The project of a better linking in Inkscape done with the students was half finished and is now in a frozen state. Contrary to other Inkscape project from the school, this one was not finished to a level an integration can be done easily. They don’t seam to be willing to continue (it was a school project, not a personal project for them) and I unfortunately cannot spend more time on it. Nicolas Dufour took the lead but he lacks of support.
    I fear that we may not see these improvements in the next Inkscape release.

  4. @Steren What kind of support does Nicolas need?

  5. Oh, that’s bad! I wrote the initial specification and I was very excited when I learned it was being developed by Sternen’s students.
    I was looking forward for that feature. It would be prilceless for my daily work.
    Let me know if I can help in any way.

  6. Hi Alexandre (and the community!),

    The relative path patch is almost working, but there are some bugs that need to be addressed (there are things that should be done when saving but still need to be implemented).
    The relink feature also has some bugs and the dialog redesign is far from being finished.
    I plan to work on the relative patch in the upcoming weeks (IMHO, it must be fixed for 0.49!), but we also have to discuss if we always want a relative path or need a new preference entry. I’ll ask the dev list as soon as I have some working code.

    AP>What kind of support does Nicolas need?

    I needed some comments from the students on how they decided to implement the code the way they did, and what other ideas they have had. But sadly, I didn’t received any feedback (even negative).

  7. Wow, so good!

  8. This is a fantastic tutorial! It answered multiple questions that I had.

  9. Can you link other Inkscape SVG files? E.g. in a web site design, I have several items that common among pages, such as a page header. I would like to create one page header file, and include it into other pages. That way, all I need to do is update the page header file to make changes to all other pages.

Tell us what you think

Submit the word you see below: