Help with embedding svg files

Hello everyone,

I'm trying to create a graph that has svg images embedded within it, and then output the whole thing as an svg image, and I've been running into some issues.

I'm using graphviz version 2.30.1

Here is a small example of the type of dot file that I'm creating that reproduces the problem for me.

digraph "Kegg_egfr_TEST6.dot" {
graph [bgcolor=transparent, fontcolor=black, ratio=fill, splines=TRUE, rank=same, size="6.99,6.99", rankdir=TB];
node [label="\N", shape = none, fillcolor=transparent, fontcolor=black, fontsize=16, height="1.5", width="1.0", labelloc=b];
edge [headport=center, color=black, dir=none, weight="1.0", fontcolor=black, arrowhead=none, arrowtail=none, fontsize=14, labelfontsize=11, arrowsize=1, style=solid, minlen=1];
graph [bb="0 0 2452 2207"];
"hsa:2549" [label=GAB1,image="nodeGAB1Image.svg",imagescale=true,fixedsize=true];
"hsa:6654" [label=SOS1,image="nodeSOS1Image.svg",imagescale=true,fixedsize=true];
"hsa:2885" [label=GRB2,image="nodeGRB2Image.svg",imagescale=true,fixedsize=true];
"hsa:2885" -> "hsa:6654":center [dir=forward, weight=1, arrowhead=open];
"hsa:2885" -> "hsa:2549":center [dir=forward, weight=1, arrowhead=open];

}

When I run dot -Tsvg on this dot file, I get an svg that I can view in my browser and it looks fine. However, when I try to open it with Inkscape, or the Graphviz viewer, the node images do not appear.
From reading various help sites, and from the error I'm getting on Inkscape, I think the problem might be that the svg file has the node images are "linked", but not "embedded". Is there a way to get graphviz to embed the images, so that they will show up in Inkscape or Graphviz?
Or is it that I'm doing something incorrectly in my dot?
Any help or advice would be appreciated.

Thanks

I'm not able to repoduce the

I'm not able to repoduce the problem. Of course, I replaced your *Image.svg files with svg files on hand, but the output looks fine in Inkscape and browsers. (Not sure what you mean by the Graphviz viewer.)

However, if you feel that the problem is related to the svg output using a link to the images rather than having them embedded, try using -Tsvg:cairo. The cairo-based renderer includes all the necessary font and image information, so the svg file is indepedent of the machine or svg viewer used.

Thanks.  I tried running it

Thanks.  I tried running it with cairo as you suggested (I had to install cairo first).

I ran dot -Tsvg:cairo on the above file, and got a bunch of :

"Warning: No loadimage plugin for "svg:cairo""

There is mention of a similar error on the FAQ regarding gif images, but the solution seems to be to update graphviz and (I think?) 2.30.1 (which I'm running) is the latest release version.

What machine are you running

What machine are you running on? I thought most of the Linux distributions came with cairo, and we put it into the Graphviz Windows package.

Assuming you are building from source, after you installed cairo, you need to re-run the Graphviz configure script. This will attempt to find cairo and friends on your machine, and report if it failed at the end. (Using cairo is the default.) If configure didn't find cairo, you can use some of its options to help it find where you installed it. Once it claims to have what is needs, you then need to rebuild and reinstall Graphviz so it can use the cairo libraries.

If you are using RPMs or such, I'll have to dig deeper.

I'm running Graphviz on an

I'm running Graphviz on an imac OS X Version 10.8.3.  I didn't install Graphviz  from source, all I did was download the .pkg for mountainlion and run that.  

Okay, it turns out that the

Okay, it turns out that the Mountain Lion package does not have svg image loading enabled. I'll try to find out why not and see if we can turn it on. As a possible workaround, if you use macports, that version of graphviz has this enabled.

Thanks for pointing this out.

I just reinstalled graphviz

I just reinstalled graphviz using macports.  It appeared to install correctly, but I'm still having the same problems.  Just as before...

dot -Tsvg:cairo   

gives...

Warning: No loadimage plugin for "svg:cairo"

dot -Tsvg

 gives an image file where the embedded images won't show up in Inkscape.  

If you are willing to go the

If you are willing to go the macports route, we should be able to make this work. At least, I have built graphviz using macports on mountain lion and it handles svg files.

Please try two things: run 

 port installed graphviz

to see what graphviz variant you've installed, and run

  /opt/local/bin/dot -v

(You'll need to interrupt the process as it's waiting for input.) Post the output you get from these.

Basically, the build has to include pangocairo and librsvg. In fact, it may be faster to redo the macports install as

  port install graphviz @2.30.1_1+pangocairo+rsvg+x11

and see if that fixes the problem.

 

I ran "port install graphviz

I ran "port install graphviz @2.30.1_1+pangocairo+rsvg+x11"

This seems to have done the trick.  Thanks so much for all of your help.

We have a server here that

We have a server here that runs GNU linux and it has a graphviz install (version 2.26.0).  I copied my files over to that cluster and tried to generate the graph in the same way.  I ran into the exact same problems there.  I thought maybe there was something wrong with my svg files that might be causing the issue, but I get the same result with a simple rectangle svg file that I copied off the wikipedia entry for svg.

Regarding your earlier suggestion for linux, I'm not sure if I can run the configure script on the linux machine, because I don't have root priveleges.

Recent comments