giorgioca
giorgioca

Reputation: 713

data URI and Graphviz

Is it possible to use the Graphviz [image] tag to embed a data URI string? i.e.

simple.dot: (should display a red dot image -> node B)

digraph G {

rankdir="LR";
A -> B [label="test 1"];

A [image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="];
B [label="foo"];

}

Running this with

dot simple.dot -o simple.svg -Tsvg

this is the error I'm getting

Warning: No such file or directory while opening data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
Warning: No or improper image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" for node "A"

The resulting graph is displayed without the image in node A .

Would you have any idea how to fix this?

Thanks!

Upvotes: 2

Views: 1166

Answers (1)

Erik Dahlström
Erik Dahlström

Reputation: 60966

You'd probably have to modify the source of graphviz to become capable of reading/writing data uris. Presumably it needs to load the image to get the dimensions.

Another option is to not use data uris in the dot files, and instead postprocess the resulting svg (if what you wanted was a selfcontained svg file). SVG Scour might be one way to do that easily. Inkscape can probably also do this for you.

Upvotes: 2

Related Questions