goccy / go-graphviz

Go bindings for Graphviz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot render image after setting node SetImage

tntobias opened this issue · comments

I'm attempting to render a graph containing nodes with png icons.

node, _ := graph.CreateNode("mynode")

node.SetImage("/path/to/image.png")

When the graph is rendered:

g.RenderFilename(graph, "png", "mygraph.png")

I'm getting an error:

No loadimage plugin for "png:png"

Rendering to "dot" format and creating the image with graphviz works as intended.

I've attempted to troubleshoot and as near as I can tell, the pango/cairo plugin must be enabled to allow this but I'm not familiar enough with the C/Go bindings to know how this could be done. For what it's worth, I've tried #define HAVE_PANGOCAIRO 1 in /internal/config.h to no effect.

Any guidance on how I could enable this?

I ran into this issue as well and unfortunately could not get PNG to work.

So to work around this all I did was change it to SVG and that worked without any issues.

m.SetImage("icon_64.svg")

if err := g.RenderFilename(graph, graphviz.SVG, "graph.svg"); err != nil {
	log.Fatal(err)
}

Hope this perhaps help you.