goccy / go-graphviz

Go bindings for Graphviz
MIT License
603 stars 66 forks source link

Cannot render image after setting node SetImage #30

Open tntobias opened 4 years ago

tntobias commented 4 years ago

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?

kheadjr-rv commented 3 years ago

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.

CiucurDaniel commented 4 months ago

Currently running into the same issue: error rendering graph to jpg: No loadimage plugin for "png:jpg"

Is there any known fix for this? Issue is already 4 years old.