1. User guide
  2. Reference

The Command Line

Chapter 19 of 19 12 min read

Chapters19 of 19
On this page6 sections
  1. How it works
  2. The commands
  3. The license
  4. Exit codes
  5. Output for scripts
  6. Example scripts

NightScape Lab comes with a command line, nightscape, for people who'd rather script their nights than click through them. The tools that build the picture are all there: stack, star trails, panorama, merge, star removal, Round Stars, Defringe & SCNR, Sky White Balance, denoise and the sky mask. Each command takes files in and writes new files out, with the same settings and defaults as the app, and it uses the app's license on that computer.

It works on files only. It doesn't open the app, touch your catalog, or use presets and the Process sliders. A photo is never changed: every command writes new files.

Put nightscape on your PATH

The command comes inside the app, so it's always the version of the app you have installed, and an update brings it along with no setup.

Mac. In Terminal, run these two lines once (the first asks for your Mac password):

sudo mkdir -p /usr/local/bin

sudo ln -sf "/Applications/NightScape Lab.app/Contents/Resources/bin/nightscape" /usr/local/bin/nightscape

If the app lives somewhere other than Applications, change the path to match.

Windows. The command is nightscape.cmd in the folder you unzipped NightScape Lab into. Add that folder to your PATH: Start > "Edit environment variables for your account" > Path > Edit > New, paste the folder, then OK.

Linux. The command is nightscape in the folder you unpacked from the .tar.gz download. Link it into a folder on your PATH:

mkdir -p ~/.local/bin

ln -sf ~/NightScapeLab-1.0.1-linux-x86_64/nightscape ~/.local/bin/nightscape

Change the folder name to the one you unpacked. If you run the AppImage, get the .tar.gz as well for the command line, since the command sits inside the unpacked folder.

Open a new terminal window and check it:

nightscape version

It prints the version, the same one About shows: NightScape Lab 1.0.1.

How it works

nightscape <command> [files] [options]

nightscape --help

nightscape <command> --help

nightscape on its own, or with --help, lists the commands. Every command's --help lists its options with their defaults, the files it writes, and examples.

Where results go. Without -o, a result goes beside the first input, named after it and the tool. The table below has the names. With -o, you name the file (or, for merge, the folder). Two commands write a second file beside the first: stack writes its sky mask, and stars in remove mode writes the star map.

Nothing is written over. If an output file already exists, the command stops before doing any work and says so. Add --overwrite to replace it. An output that is one of your inputs is always refused, even with --overwrite. If a command fails or you stop it, no half-written file is left behind, and a file that --overwrite was about to replace is put back.

Files. Commands take RAW files (.arw .cr2 .cr3 .nef .dng .orf .raf .rw2 .pef .srw) and TIFF, JPEG or PNG. Where a command takes several frames, you can give a folder, and it takes the photos in it in name order. A single-image tool given a RAW develops it first, the way the app does when you open one. Results are 16-bit linear ProPhoto TIFFs with the profile embedded, like the app's base images.

Darks. stack, trail and pano take dark frames with --darks, and never need them. Darks are used only when you name them. A folder called darks next to your lights is ignored unless you name it.

Default output names

CommandWrites, when you don't use -o
stack<first light>-stack.tif, and its sky mask <output>-mask.png
trail<first frame>-trails.tif
pano<first frame>-pano.tif
mergeA folder <foreground>-merge holding merged.tif, foreground.tif, sky.tif and mask.tif
prepare-raw<raw>-prepared.tif
stars<input>-starless.tif, -reduced.tif or -dimmed.tif by mode. Remove also writes <output>-starmap.tif.
roundstars<input>-roundstars.tif
defringe<input>-defringe.tif
starglow<input>-starglow.tif
wb<input>-wb.tif
denoise<input>-denoise.tif
mask<input>-mask.png

So nightscape stack on _DSC6181.ARW and its neighbours writes _DSC6181-stack.tif and _DSC6181-stack-mask.png, and nightscape stars stack.tif writes stack-starless.tif and stack-starless-starmap.tif.

Options every tool has

OptionWhat it does
-o, --outputWhere the result goes (a file, or a folder for merge)
--overwriteReplace output files that already exist
--jsonPrint one JSON object with the result on stdout
--verboseShow the engine's own log on stderr
--quiet-progressDon't print progress on stderr

license takes only --json and --verbose. version takes none of them.

Each on/off setting from the app is a pair of options here: --purple-fringe turns it on and --no-purple-fringe turns it off. The tables below show both.

The commands

stack

Stacks light frames on the stars while keeping the ground still, split by the AI sky mask, as Stack Frames does. Writes the stacked TIFF and its sky mask. It needs at least two light frames, all RAW or all TIFF, JPEG and PNG.

nightscape stack ~/Night/lights --darks ~/Night/darks -o ~/Night/stack.tif

OptionWhat it does
--darks DARKDark frames or a folder of them (default: none)
--rejection NRejection (sigma), 1.5 to 5.0: lower removes more satellites, planes and hot pixels (default: 3.0)
--remove-satellite-and-plane-trails, --no-remove-satellite-and-plane-trailsRemove satellite and plane trails (default: on)

trail

Makes star trails from frames in capture order, as Star Trails does. It needs at least two frames, all RAW or all TIFF, JPEG and PNG.

nightscape trail ~/Night/trails --look comet --sky-darkness 90

OptionWhat it does
--darks DARKDark frames or a folder of them (default: none)
--look solid, comet, meteor, fade, vortexLook (default: solid)
--sky-darkness NSky darkness, 0 to 100 (default: 85)
--tail-length NTail length for comet and meteor, 2 to 100 (default: 30 for comet, 3 for meteor)
--vortex NVortex zoom for the vortex look, 5 to 50 (default: 25)
--foreground clean, singleForeground: clean or single frame (default: clean)
--remove-plane-and-satellite-streaks, --no-remove-plane-and-satellite-streaksRemove plane and satellite streaks (default: on)
--star-point-trail-heads, --no-star-point-trail-headsStar-point trail heads (default: off)
--fill-gaps-between-frames, --no-fill-gaps-between-framesFill gaps between frames (default: on for meteor, off for the other looks)
--auto-white-balance, --no-auto-white-balanceAuto white balance, estimated from the sky (default: off)
--defringe, --no-defringeDefringe the finished trails with the four rows below (default: off)
--purple-fringe, --no-purple-fringePurple fringe (default: on)
--purple-fringe-amount NPurple fringe amount, 0 to 100 (default: 80)
--green-fringe, --no-green-fringeGreen fringe (default: off)
--green-fringe-amount NGreen fringe amount, 0 to 100 (default: 80)
--remove-green-cast, --no-remove-green-castRemove green cast (SCNR) (default: off)
--remove-green-cast-amount NRemove green cast (SCNR) amount, 0 to 100 (default: 80)
--remove-blue-cast, --no-remove-blue-castRemove blue cast (SCNR) (default: off)
--remove-blue-cast-amount NRemove blue cast (SCNR) amount, 0 to 100 (default: 80)

pano

Stitches a Milky Way panorama. Give each panel with its own --panel, in shooting order, and at least two of them. A panel of two or more frames is stacked first. Panoramas take RAW frames.

nightscape pano --panel row1/*.ARW --panel row2/*.ARW --panel row3/*.ARW -o pano.tif

OptionWhat it does
--panel FRAMEOne panel's RAWs or folder. Repeat it for each panel.
--darks DARKDark frames or a folder of them (default: none)

merge

Takes the sky from one photo and the ground from another. Writes a folder with merged.tif and its layers: foreground.tif, sky.tif and mask.tif. Both --sky and --foreground are required.

nightscape merge --sky stack.tif --foreground blue-hour.ARW -o merged

OptionWhat it does
--sky FILEThe sky photo (often a stack)
--foreground FILEThe foreground photo
--framing auto, registered, compositeFraming: auto (Auto-detect), registered (Same shot, locked tripod), composite (Different sky) (default: auto)
--color-match-foreground-to-sky, --no-color-match-foreground-to-skyColor match foreground to sky (default: on)
--match-strength NMatch strength, 0 to 100 (default: 100)
--keep-foreground-brightness, --no-keep-foreground-brightnessKeep foreground brightness (default: on)
--match-grain-across-the-horizon, --no-match-grain-across-the-horizonMatch grain across the horizon (default: on)

prepare-raw

Develops one RAW to a linear TIFF with nothing baked in, as the app does when it opens a RAW.

nightscape prepare-raw _DSC6164.ARW

It has no options of its own beyond the common ones.

stars

Remove writes a starless image and its star map, which add back up to the photo. Reduce shrinks stars up to a size. Dim takes all of them down.

nightscape stars stack.tif

nightscape stars stack.tif --mode reduce --max-star-size 4 --reduction 60

OptionWhat it does
--mode remove, reduce, dimRemove, Reduce or Dim (default: remove)
--max-star-size NMax star size for reduce, 1 to 15 (default: 4)
--reduction NReduction for reduce, 0 to 100 (default: 60)
--strength NStrength for dim, 0 to 100 (default: 50)
--denoise-the-starless-sky, --no-denoise-the-starless-skyDenoise the starless sky (default: off)
--luminance NLuminance for the starless sky's denoise, 0 to 100 (default: 50)
--color-noise NColor noise for the starless sky's denoise, 0 to 100 (default: 60)

roundstars

Finds stars a wide lens stretched toward the edges and corners and makes them round again, or takes them out.

nightscape roundstars stack.tif --oblong-above 2.5

OptionWhat it does
--mode round, removeRound or Remove (default: round)
--oblong-above NOblong above, 1.5 to 4.0 (default: 2.0)
--leave-long-stars-as-shot, --no-leave-long-stars-as-shotLeave long stars as shot (default: off)
--longer-than NLonger than, in pixels, 5 to 80 (default: 20)

defringe

Defringe & SCNR: purple and green fringes around stars, a green or blue cast, and over-coloured stars. Each row turns on or off, with its amount.

nightscape defringe stack.tif --green-fringe --remove-green-cast --remove-blue-cast --neutralize-star-color

OptionWhat it does
--purple-fringe, --no-purple-fringePurple fringe (default: on)
--purple-fringe-amount NPurple fringe amount, 0 to 100 (default: 80)
--green-fringe, --no-green-fringeGreen fringe (default: off)
--green-fringe-amount NGreen fringe amount, 0 to 100 (default: 80)
--remove-green-cast, --no-remove-green-castRemove green cast (SCNR) (default: off)
--remove-green-cast-amount NRemove green cast (SCNR) amount, 0 to 100 (default: 80)
--remove-blue-cast, --no-remove-blue-castRemove blue cast (SCNR) (default: off)
--remove-blue-cast-amount NRemove blue cast (SCNR) amount, 0 to 100 (default: 80)
--neutralize-star-color, --no-neutralize-star-colorNeutralize star color (default: off)
--neutralize-star-color-amount NNeutralize star color amount, 0 to 100 (default: 80)
--even-star-color, --no-even-star-colorEven star color (default: off)
--even-star-color-amount NEven star color amount, 0 to 100 (default: 80)

starglow

Star Glow: a soft glow in a bright star's own color. Give each star as fractions of the width and height, so 0.5,0.5 is the middle of the picture.

nightscape starglow stack.tif --star 0.412,0.287 --star 0.660,0.143 --size 1

OptionWhat it does
--star X,YA star to glow, as fractions of the width and height, 0 to 1 each. Give it once for each star.
--size NSize: how far the glow reaches, as a percent of the long edge, 0.1 to 25 (default: 2)
--amount NAmount, or the Flow of one dab with --manual, 0 to 100 (default: 50)
--manualManual: one soft dab at the size for each --star, in place of the whole glow
--snap-to-star, --no-snap-to-starSnap to star: start the glow at the star's center near the point you gave (default: on)

wb

Sky White Balance. It measures the sky alone with the AI sky mask, as the app does, and writes the whole photo balanced by it. The app only sets Temp and Tint. A file has no sliders, so here the balance is written into the pixels. The gains it applied are printed on stderr and in --json.

nightscape wb stack.tif

It has no options of its own beyond the common ones. If the sky is too small or too dark to measure, the command fails and says so, and nothing is written.

denoise

Star-safe denoise: it separates the stars, denoises the sky and puts the stars back.

nightscape denoise stack.tif --strength 70

OptionWhat it does
--strength NStrength, 0 to 100 (default: 50)

mask

Writes the AI sky mask as a PNG: white sky, black ground.

nightscape mask stack.tif

It has no options of its own beyond the common ones.

license

nightscape license status prints the license state. nightscape license activate asks for your key without showing it, or reads it from stdin in a script. The key is never typed as part of the command, so it doesn't show in the process list or your shell history. nightscape license deactivate frees this computer's seat. It's the same license as the app's on this computer: activate or deactivate in either and it counts for both.

nightscape license status

pbpaste | nightscape license activate

version

Prints the version, the same one About shows.

The license

Every tool checks the license before it reads anything. Help, version and the license commands work without one.

StatusWhat it means
licensedThe tools run, online or off, until the 14-day lease runs out.
warningThe lease ran out offline. "Connect to the internet so NightScape Lab can check your license."
unlicensedThis computer isn't activated, or the license server didn't renew it.
revokedThe key was turned off on the license server.

When the license refuses a tool, the command prints a line that starts nightscape: license, with the status and the reason, and exits with code 3.

Exit codes

CodeMeaning
0Done
1The tool failed (the message says why)
2A usage error: an unknown command or option, a value out of range, a file it can't open, or an output that exists. Nothing was written.
3The license refused the tool, or license status found it not licensed
130Stopped with Ctrl-C

Output for scripts

Progress and messages go to stderr. On stdout there's only the path of each file written, one per line, so this works:

out=$(nightscape denoise stack.tif --quiet-progress)

license status prints the status word on stdout.

With --json, stdout holds exactly one JSON object, whether the command worked or not:

FieldWhat it holds
commandThe command
oktrue when it worked
secondsHow long it took
inputsThe files it read
settingsThe settings it used, defaults included
outputsThe files it wrote
lights, darks, frames, panelsHow many of each it used, for the commands that take them. panels is a list with the frame count of each panel.
gainsFor wb, the red, green and blue gains it applied
engineFor the single-image tools, the plain values the engine reported back
licenseThe license status, from the license commands and when the license refused a tool
message, activated, deactivatedFrom the license commands
errorOn failure, a code (usage, license_required, failed, stopped) and a message

Example scripts

Each of these is one line you can paste into a shell script.

Denoise every TIFF in a folder, into a folder of its own:

mkdir -p ~/Night/denoised

for f in ~/Night/edits/*.tif; do nightscape denoise "$f" --strength 60 -o ~/Night/denoised/"$(basename "$f")" --quiet-progress || echo "skipped or failed: $f"; done

Run it again after adding more files and it only does the new ones. The files already in denoised are refused, because the output exists.

Stack each night's lights with its darks, for nights that each have a lights and a darks folder:

for night in ~/Nights/*/; do nightscape stack "$night/lights" --darks "$night/darks" -o "$night/stack.tif"; done

Remove the stars, then denoise the starless image and keep the star map for later:

starless=$(nightscape stars stack.tif --quiet-progress | head -n 1) && nightscape denoise "$starless" --strength 70 --quiet-progress