RenderDOTToFile renders DOT source to an image file using the diagram engine (embedded go-graphviz, with the system `dot` as an optional sharper backend per CHATCLI_DIAGRAM_BACKEND). format defaults to png and engine to dot when empty; dpi defaults to a legible 96 when not positive; output defaults
(ctx context.Context, dotSrc, format, engine, output string, dpi int)
| 18 | // empty; dpi defaults to a legible 96 when not positive; output defaults to a |
| 19 | // temp file when empty. Returns a human summary that includes the written path. |
| 20 | func RenderDOTToFile(ctx context.Context, dotSrc, format, engine, output string, dpi int) (string, error) { |
| 21 | if format == "" { |
| 22 | format = "png" |
| 23 | } |
| 24 | if engine == "" { |
| 25 | engine = "dot" |
| 26 | } |
| 27 | if dpi <= 0 { |
| 28 | dpi = 96 |
| 29 | } |
| 30 | cfg := diagramArgs{ |
| 31 | Cmd: "render", |
| 32 | DOT: dotSrc, |
| 33 | Format: format, |
| 34 | Engine: engine, |
| 35 | Style: "dark", |
| 36 | Backend: configuredDiagramBackend(), |
| 37 | Output: output, |
| 38 | DPI: dpi, |
| 39 | } |
| 40 | cfg, err := finalizeDiagramArgs(cfg) |
| 41 | if err != nil { |
| 42 | return "", err |
| 43 | } |
| 44 | return diagramRenderAndWrite(ctx, dotSrc, cfg) |
| 45 | } |