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.png

Input#

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#

OptionDescription
inputThe diagram JSON file, or - for standard input.
-o, --outputThe output file, or - for standard output. Defaults to the input's name with the format's extension.
-f, --formatsvg, png or jpg. Defaults to the output's extension, else svg.
-t, --themelight, the default, or dark.
--transparentLeaves out the background. SVG and PNG only.
-s, --scalePixels per unit for PNG and JPG. Defaults to 2.
-V, --versionPrints the version.
-h, --helpPrints the options.
  • -f wins over the output's extension, and an extension other than .svg, .png, .jpg or .jpeg needs 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 --scale pixels per unit, lowered to keep each side within 16384 pixels.
  • --theme dark draws 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-Lamda

The 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.

ErrorFix
nodes[2].position.x must be a numberThe file doesn't match the format. Fix the field at that path.
nodes must be an arrayThe file isn't a single page. Render each page from its own file.
diagram is emptyThe page has no nodes or arrows.
cannot infer format from "diagram.out", pass --formatUse a .svg, .png, .jpg or .jpeg output, or pass -f.
jpg output needs PillowInstall 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#

StatusMeaning
0The image was written.
1Rendering failed, or the image couldn't be written.
2The command line was invalid, such as an unknown option or format.