Graphviz doesn't render jpg images

I can’t embed jpg into a node. Following produces corrupt png/jpeg/pdf output:

@"
digraph {
abc [shape=box label="" image="C:\Users\user\Pictures\ROMANOVS\200px-M35495250.jpg" ]
}
"@ | dot -Tpng -O; start noname.gv.png

But with -Tsvg, image is displayed correctly. When png file is used as image input, it works fine. Graphviz doesn’t support embedding jpg images?

According to this scheme it should work: Output Formats | Graphviz

dot - graphviz version 12.2.1 (20241206.2353)
Using render: cairo:cairo
Using device: png:cairo:cairo
libdir = "C:\Users\user\AppData\Local\Programs\Graphviz-12.2.1-win64\bin"
Activated plugin library: gvplugin_dot_layout.dll
Using layout: dot:dot_layout
The plugin configuration file:
        C:\Users\user\AppData\Local\Programs\Graphviz-12.2.1-win64\bin\config6
                was successfully loaded.
    render      :  cairo dot dot_json fig gd gdiplus json json0 map pic pov ps svg svg_inline tk vrml xdot xdot_json
    layout      :  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
    textlayout  :  textlayout
    device      :  bmp canon cmap cmapx cmapx_np dot dot_json emf emfplus eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg json json0 kitty kittyz metafile pdf pic plain plain-ext png pov ps ps2 svg svg_inline svgz tif tiff tk vrml vt vt-24bit vt-4up vt-6up vt-8up wbmp webp xdot xdot1.2 xdot1.4 xdot_json
    loadimage   :  (lib) bmp eps gd gd2 gif jpe jpeg jpg png ps svg webp
pack info:
  mode   undefined
  size   0
  flags  0
  margin 8
pack info:
  mode   node
  size   0
  flags  0
network simplex:  1 nodes 0 edges maxiter=2147483647 balance=1
network simplex: 1 nodes 0 edges 0 iter 0.00 sec
Maxrank = 0, minrank = 0
mincross: pass 0 iter 0 trying 0 cur_cross 0 best_cross 0
merge2: graph %1, rank 0 has only 1 < 2 nodes
mincross %1: 0 crossings, 0.00 secs.
network simplex:  1 nodes 0 edges maxiter=2147483647 balance=2
network simplex: 1 nodes 0 edges 0 iter 0.00 sec
routesplines: 0 edges, 0 boxes 0.00 sec
Using render: cairo:cairo
Using device: png:cairo:cairo
dot: allocating a 177K cairo image surface (213 x 213 pixels)
Using render: cairo:cairo
Activated plugin library: gvplugin_gd.dll
Using loadimage: jpeg:cairo:gd

I don’t believe that Graphviz will convert images from one format (e.g. jpg) to another (e.g. png)

So, either try explicitly converting the jpg to a png before running dot (lots of programs will do this) or try producing a jpg as output.

I thought this should work.

My apologies, I assumed it shouldn’t work but I didn’t test it.
It does work on Linux, but not on Windows (at least not on Graphviz 12.2.1). A zero length file is created.

I have created an issue for this bug.

1 Like