Rendering diagrams
lineout turns a diagram page saved as JSON into an SVG, PNG or JPG image.
lineout architecture.json # writes architecture.svg
lineout architecture.json -o architecture.png # format from the extension
lineout architecture.json -f png # writes architecture.png
lineout architecture.json -o dark.jpg --theme dark --scale 3
cat architecture.json | lineout - -f png -o - > architecture.pngInput#
One page in the diagram format, { "nodes": [...], "arrows": [...] }, such as a page exported as JSON. A document with several pages fails with nodes must be an array, so render each page from its own file.
Options#
| Option | Description |
|---|---|
input | The diagram JSON file, or - for standard input. |
-o, --output | The output file, or - for standard output. Defaults to the input's name with the format's extension. |
-f, --format | svg, png or jpg. Defaults to the output's extension, else svg. |
-t, --theme | light, the default, or dark. |
--transparent | Leaves out the background. SVG and PNG only. |
-s, --scale | Pixels per unit for PNG and JPG. Defaults to 2. |
-V, --version | Prints the version. |
-h, --help | Prints the options. |
-fwins over the output's extension, and an extension other than.svg,.png,.jpgor.jpegneeds it.- The output's folder must exist, and an existing file is replaced without asking.
- With
-as the input and no-o, the image goes to standard output. Warnings and update notices always go to stderr.
What the image looks like#
- Everything on the page, labels included, cropped to the content with a 32-unit margin.
- Arrows take the same routes as in the editor.
- SVG is one pixel per unit, with its icons and fonts embedded.
- PNG and JPG are
--scalepixels per unit, lowered to keep each side within 16384 pixels. --theme darkdraws on a dark background and uses the dark versions of icons. JPG always has a background.
Image nodes are drawn as placeholders, because the CLI can't sign in to fetch uploaded pictures. To include them, export from the editor.
Warnings#
lineout: warning: icon not found: AWS-LamdaThe image is still written, with a gap where the icon belongs. Check the name, for example in the editor's code panel, or upgrade the CLI if the icon is new.
Errors#
Errors print lineout: error: and the problem on stderr, and no image is written.
| Error | Fix |
|---|---|
nodes[2].position.x must be a number | The file doesn't match the format. Fix the field at that path. |
nodes must be an array | The file isn't a single page. Render each page from its own file. |
diagram is empty | The page has no nodes or arrows. |
cannot infer format from "diagram.out", pass --format | Use a .svg, .png, .jpg or .jpeg output, or pass -f. |
jpg output needs Pillow | Install the jpg extra. The message includes the command. See Installing the CLI. |
Invalid JSON fails with the parser's message, and files that can't be read or written with the system's, such as No such file or directory. When the content is the problem and a newer lineout-cli is out, the CLI also says the file may need it. See Updates.
Exit status#
| Status | Meaning |
|---|---|
0 | The image was written. |
1 | Rendering failed, or the image couldn't be written. |
2 | The command line was invalid, such as an unknown option or format. |