# Image Node Definition

**URL:** <https://forum.graphviz.org/t/image-node-definition/1066>\
**Category:** Help\
**Created:** [March 10, 2022, 3:18pm UTC](https://forum.graphviz.org/t/image-node-definition/1066 "2022-03-10T15:18:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)\
**Post date:** [March 10, 2022, 3:18pm UTC](https://forum.graphviz.org/t/image-node-definition/1066/1 "2022-03-10T15:18:02Z")

</div>

creating a subgraph with an image image node, I have tried:  
subgraph cluster\_1 {  
node [label="" image=“image-name.png”]  
}

“image-name.png” is a file that is located in the same directory as the dot file. Is there another syntax that I am not using to accomplish this functionality?

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [March 10, 2022, 3:56pm UTC](https://forum.graphviz.org/t/image-node-definition/1066/2 "2022-03-10T15:56:28Z")

</div>

[Please include code as “preformatted text”. Otherwise, the forum software changes certain characters (like ") to non-ascii characters. That makes it very hard to cut-and-paste an example to experiment with it on my system]

This `node [label="" image=“image-name.png”]` means (more or less) _for all nodes defined within the current subgraph after this point, set label to “” and use the named image_ But, you have not defined any actual nodes - explicitly or implicitly.

Try this - it defines a node named _MyCoolNode_ :

```auto
subgraph cluster_1 {
  MyCoolNode [label="" image="image-name.png"]
}

```

---

<div class="post-metadata">

**Author:** ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)\
**Post date:** [March 10, 2022, 6:59pm UTC](https://forum.graphviz.org/t/image-node-definition/1066/3 "2022-03-10T18:59:25Z")

</div>

I have defined the image node as:

```auto
subgraph cluster_1 {
  MyCoolNode [label="" image="image-name.png"]
}

```

but I get a problem loading image error: " problem loading image /./image-name.png"  
My png image is in the same directory as the dot file that I have defined this subgraph.

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [March 10, 2022, 8:22pm UTC](https://forum.graphviz.org/t/image-node-definition/1066/4 "2022-03-10T20:22:23Z")

</div>

What OS are you using?  
Also, please show the command line you are using and run the command `dot -V`, to show the version of the software.

---

<div class="post-metadata">

**Author:** ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)\
**Post date:** [March 11, 2022, 1:31pm UTC](https://forum.graphviz.org/t/image-node-definition/1066/5 "2022-03-11T13:31:21Z")

</div>

when I run `dot -v`, I get:

```auto
dot - graphviz version 2.50.0 (20211204.2007)

```

Is this version not compatible for inserting a png in this way?

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [March 11, 2022, 6:29pm UTC](https://forum.graphviz.org/t/image-node-definition/1066/6 "2022-03-11T18:29:14Z")

</div>

2.50.0 is fine (nice and new. some folks end up with quite old versions of Graphviz. annoying).  
I’m more interested in your OS. My guess is some version of Windows.

> " problem loading image /./image-name.png"

This tells me that Graphviz believes that “/” (\*C:\* to Windows users) is your _current working directory_. Maybe it is and maybe it isn’t.  
The **imagepath** attribute ([imagepath | Graphviz](https://graphviz.org/docs/attrs/imagepath/)) should solve this.
