# Controlling png size

**URL:** <https://forum.graphviz.org/t/controlling-png-size/1742>\
**Category:** Help\
**Created:** [August 20, 2023, 12:40pm UTC](https://forum.graphviz.org/t/controlling-png-size/1742 "2023-08-20T12:40:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![p789](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@p789](https://forum.graphviz.org/u/p789)\
**Post date:** [August 20, 2023, 12:40pm UTC](https://forum.graphviz.org/t/controlling-png-size/1742/1 "2023-08-20T12:40:32Z")

</div>

Hi,

I am trying to use graphviz to create icons consisting of a single html-node that fills the entire image and I want to be able to control the size of the resulting png.

I can as an example create a 100x100 png like this:

```auto
 graph G {
     bgcolor=transparent
     size="1!"
     dpi=100
     margin=0.0
     pad=0.0
       a [
        shape = plain
        label = <<table padding="0" cellspacing="0" border="1" cellborder="1">
                    <tr height="50">
                       <td rowspan="2" height="50" width="50" bgcolor="black"></td>
                       <td height="50" width="50" ></td>
                    </tr>
                    <tr>
                       <td height="50" width="50" ></td>
                    </tr>
                </table>>
    ]
   }

```

But what I don’t like about this is that while setting dpi to 100 and size to 1 I get a 100x100 image, I then also need to explicitly set the height and width of table elements to half of the desired size and that’s not exactly elegant…

So my question: Is there a better way to do this?

---

<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:** [August 21, 2023, 8:47pm UTC](https://forum.graphviz.org/t/controlling-png-size/1742/2 "2023-08-21T20:47:39Z")

</div>

It is always fun to encounter a new Graphviz use.  
The “html-like” code seems to insist on making things as small as possible, no matter what the user wants, so you are probably stuck with specifying **height** & **width**. If this is programmatically-generated, maybe not a big deal?

Depending on the complete nature of the desired icons, you might consider not using “html-like” nodes; instead explicitly placing rectangular nodes butted-up to each other or on top of each other. see [FAQ | Graphviz](https://graphviz.org/faq/#FaqDotWithCoords)
