Opened 9 years ago

Last modified 6 years ago

#5663 new defect

Graphviz SVG output Scaled poorly with default setting of DPI = 96

Reported by: Russ Tyndall Owned by: Peter Kropf
Priority: normal Component: GraphvizPlugin
Severity: major Keywords:
Cc: evgley@…, Mitar Trac Release: 0.11


I am upgrading from an old trac install to a new trac install on a new server. My old install was trac-11.5-stable running graphvizplugin-0.6.9.

All my graphs on the new setup were scaled badly and the viewport cut off some of the details on the side/bottom of the graph.

I tracked the thing that changed down to emitting the dot param -Gdpi=96. (In the older version I was using this param was elided). Without this parameter everything renders correctly. I fixed this by setting the following in my trac.ini, but this seems like unintended behaviour either way.

default_graph_dpi = 72

Running on Trac-0.11.6stable_r8458-py2.6

$ svn info
Path: .
Repository Root:
Repository UUID: 7322e99d-02ea-0310-aa39-e9a107903beb
Revision: 6365
Node Kind: directory
Schedule: normal
Last Changed Author: cboos
Last Changed Rev: 5995
Last Changed Date: 2009-06-09 04:27:19 -0400 (Tue, 09 Jun 2009)
and the latest graphvizplugin 0.7.6dev-r6365

How to Reproduce

Render any graph through dot with the mentioned version with the default setting of dpi=96. Observe that the graph is scaled wrong and cuts off the edge of the graph. You can see that it is scaling the whole graph by emitting the following in the svg file

<g id="graph0" class="graph" transform="scale(1.33333 1.33333) rotate(0) translate(4 58)">



Attachments (0)

Change History (7)

comment:1 Changed 8 years ago by chous

It happened to me as well. Thanks for finding a workaround, albeit the output quality seems to be affected.

comment:2 Changed 8 years ago by anonymous

Cc: evgley@… added; anonymous removed

comment:3 Changed 8 years ago by Mitar

Cc: Mitar added

No, it is some change in Trac between 0.11.4 and 0.11.6 which triggers this. I have tested with exactly the same system just different Trac versions and this problem happens in 0.11.6. The reason is that additional processor_options are parsed in new Trac version so -Gdpi=96 is added from default values when generating SVG file and everything goes bad from there as graphviz then adds scaling to SVG file. In older version defaults are not parsed the same way.

I suggest that default_graph_dpi parameter is renamed to something else as currently is not used just during SVG to PNG conversion but also when generating SVG file itself (and thus this scale factors in SVG file). I think it is useful to split this two stages so please rename default_graph_dpi to something else (used just for SVG to PNG conversion) and leave default_graph_dpi to be used just for processor_options (if somebody wants to add some options there).

In meantime proper workaround is to remove this behavior with manually unsetting this -Gdpi=96 parameter. This is achieved by adding to Trac configuration:

default_graph_dpi = 0

(I use also png_antialias and it works for me.)

comment:4 Changed 8 years ago by Daniel

By the way the behaviour of graphviz when using dpi settings and SVG rendering is a bug of graphviz itself. There's one unnecessary transformation applied in the SVG XML code.

My suggestion would be: do NOT apply the -Gdpi=... option when rendering SVG anyway. This has to be done in the code. When they fix graphviz, this option can be useful again. So do not throw it away, just filter it out for the time.

Using default_graph_dpi=72 should also serve as a workaround.

comment:5 Changed 8 years ago by EIB

Using GraphvizPlugin built from graphvizplugin/0.11/@7514. Just upgraded from Trac 0.11.1 to Trac 0.11.6 (for other issues). This issue is now happening to me as well.

default_graph_dpi=72 fixes the issue.

comment:6 Changed 8 years ago by jholg

I can confirm this problem, trying to migrate from Trac 0.11.4 to 0.11.7. What has changed in Trac 0.11.6 is the presentation of config values, i.e. when iterating over a config section you now get the default option values as well, not only those actually set in the config file. My guess is this was introduced with these caching changes to the config: (haven't looked closely)

For me default_graph_dpi=0 works better as a workaround, though with png_antialias = true the output is a bit smaller than with Trac 0.11.4, due to the parameter being used for svg generation. I agree with mitar's comments in ticket:5663#comment:3.

If this is actually a bug in graphviz I don't know but GraphvizPlugin could easily work around it, preferably by adding a separate parameter as proposed by itar.

comment:7 Changed 6 years ago by sra@…

I think this is a bug in the plugin, not in graphviz.

The plugin has a mysterious comment about having to "correct" for the size of SVG images generated by graphviz, with a magic constant correction factor of 1.35. 72 * 1.35 is suspiciously close to 96. Graphviz has different default DPI settings for different image types, and if I'm reading this correctly, the defaults for PNG and SVG are indeed 96 and 72, respectively.

As others have noted, setting default_graph_dpi=72 suffices as a workaround.

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Peter Kropf.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.