I’m using Graphviz as a library, and I’d like to render a graph like this as SVG:
digraph {
a [image="http://example.com/myimage.jpg"]
}
That is, the resulting SVG file should have an <image>
element referring to "http://example.com/myimage.jpg"
. Of course, because Graphviz needs the image dimensions to render the graph, and only local images are supported, the result is this warning: "http://example.com/myimage.jpg" was not found as a file or as a shape library member
.
However, I don’t want Graphviz (or a script like dot_url_resolve.py) to load the image – I already know its dimensions. And from looking at gvloadimage_core.c
, it seems like Graphviz only really needs to know the dimensions of the image when rendering SVG – it doesn’t need to do anything else with the image data.
Is there currently any way to provide dimensions for an image ahead of time so that Graphviz won’t try to read them from an image file that doesn’t exist?
Specifically, this is to support images in Viz.js. I did figure out an implementation of this previously, but it involves writing a dummy SVG image to the Emscripten virtual filesystem at a path like /http:/example.com/myimage.jpg
, which Graphviz will read to find its dimensions. I’m wondering if there’s a way to do it that’s less of a hack.