Ligamen

Reference

Command line

Everything that you can do by hand in the editor and that does not need the mouse can also be done from a terminal: exporting a whole set of characters before a build, repacking an atlas on a build server, checking a skeleton that a colleague sent, or merging a shared part into twenty rigs. This article is a guided tour of the command line. It groups the options by the task, shows one example for each, and says where to find the complete list. In the examples the command is python3 run.py, which runs Ligamen from its source folder, and python -m ligamen does the same. Options that start with --export- mirror the controls of the Export window, and --pack-atlas- mirrors Texture packing, so the meaning of each is already explained there.

Opening and saving without a window#

--open FILE opens a Spine JSON file, a .skel binary or a .ligamen project, and by itself it starts the editor on it. When you add an operation that writes a result, the editor window is not built at all. --save-as FILE.ligamen writes the project, and --export-spine-json FILE.json writes Spine JSON, with --export-spine-format {json,javascript,minimal}, --export-spine-minify and --export-spine-no-nonessential as in the Data section. --import-scale 2.0 rescales a Spine JSON file on the way in.

python3 run.py --open hero.json --import-scale 2.0 --save-as hero.ligamen

Merging and importing#

The options of this group repeat what the Import window does. --merge-skeleton-from FILE brings bones, slots and skins from another project, --merge-animations-from FILE brings animations, and --merge-skeleton-on-conflict chooses skip or overwrite for names that already exist. --import-images-from FOLDER adds a folder of images as new bones, slots and attachments, and --import-psd FILE does the same with the layers of a PSD file. Each has options named after it for the skin, the parent bone and the conflict rule, such as --import-images-skin and --import-psd-parent. They all run before the saving options, so a single command can merge, import and save.

Exporting#

--export-png-sequence DIR writes one transparent frame per file, and --export-animation NAME picks the animation. The same renderer feeds --export-gif, --export-apng, --export-avi, --export-mov and --export-webm, and the details of the render, --export-scale, --export-fit, --export-crop, --export-multisample, --export-crf, --export-include-audio and --export-loops, have the names of the options of the Image and Video sections. --export-html FILE writes the HTML page of HTML export and player with --export-html-background, --export-html-no-loop, --export-html-image-scale, --export-html-image-format and --export-html-baked. --export-unity DIR writes the skeleton and its atlas for Unity, and --export-spine-binary writes a binary of the version in --export-spine-binary-version.

To avoid typing every option, set them once in the editor, use Save Settings… in the Export window, and pass the file as --export-settings FILE. It makes the saved options the defaults, and flags that you type still win.

Atlases#

Packing a folder into an atlas needs no project at all.

python3 run.py --pack-atlas-from ./parts --pack-atlas-output atlas/character.atlas

The options --pack-atlas-max-width, --pack-atlas-max-height, --pack-atlas-padding, --pack-atlas-pack-mode, --pack-atlas-scale and the others have the meaning of the controls of the same names. The opposite operation is --unpack-atlas FILE.atlas --unpack-output DIR, which writes every region back as its own PNG and takes --unpack-overwrite to replace existing files.

Inspecting a file#

--info FILE prints a summary of a project or a skeleton: the Spine version, FPS, bones, slots, skins, attachments by type, constraints by kind, events, animations with their durations, and used and missing images. It does not need the interface libraries, and the exit code is 0 when the file was read and 2 when it could not be. --info-json prints the same as JSON, which is convenient in a script, and --report-unsupported FILE lists what a skeleton uses that an export would have to change.

python3 run.py --info hero.skel --info-json

Many files at once#

--batch-open-from FOLDER processes every project file in the folder in one run, and it never builds a window. It combines with the merge and import options, which then apply to each file, and with output options that name a folder: --batch-save-as-dir, --batch-export-spine-json-dir and --batch-export-spine-binary-dir. Each output is named after its input. A file that fails is reported and skipped while the rest continue, and the exit code is 1 when anything failed.

python3 run.py --batch-open-from ./rigs --batch-save-as-dir ./rigs_merged

Checking and testing#

--self-test FILE --self-test-output check.png renders the scene offscreen and writes a snapshot, which is useful as a smoke test on a build machine that has no display. The rest of the options, and their exact spelling and defaults, are listed in the command line section of the user guide of the repository, in docs/user-guide/running.md, and in the output of python3 run.py --help.