NPS Image Editor does not include AI assistance features for scripting. However you may paste the below .MD into your AI assistant of choice to help write scripts.
# NPSS: NPS Scripting Language Reference NPSS is the built-in automation language of the NPS Image Editor. This document is a complete reference for **writing and generating** NPSS scripts. Scripts are saved as `.npss` files and run from the **Script** menu, the **Script Editor**, or **Script > Run Action...**. ## At a glance - **Line-oriented.** One statement per line. Leading whitespace is ignored. - **Comments** start with `#` (whole-line only). - **Blank lines** are ignored. - **Variables** use `$Name`; assign with `Set Name=value`. Case-insensitive. - **Strings** use `"double"` or `'single'` quotes. `$Name` is interpolated inside strings; `\n` becomes a newline. - **Blocks**: `If` / `Repeat` / `ForEach Layer`, each closed by `EndIf` / `EndRepeat` / `EndForEach`. Blocks nest. - **Errors** in a command or variable show a dialog and **abort** the script (except read-only-variable writes, which only warn). ```npss # A minimal script Set Name=World Alert "Hello, $Name!" ``` ## Syntax rules 1. Each line is `CommandName rest-of-line`, split on the **first space**. 2. Whitespace before a line is trimmed, so you may indent freely for readability. 3. A line that is empty or begins with `#` is ignored. 4. Variable names are **case-insensitive**. The `$` prefix is required when *reading* (`$Foo`) and optional on the *target* of `Set` (`Set Foo=1` and `Set $Foo=1` are equivalent). ### Value resolution Any argument is resolved as follows: - `"text"` or `'text'` -> a **string literal**; `$Name` inside is interpolated and `\n` becomes a newline. - A bare number (e.g. `42`, `-3.5`) -> a **numeric literal**. - `$Name` -> the variable's value (an undefined variable resolves to `""`). - `-$Name` -> the numeric **negation** of a numeric variable. - Anything else -> treated as a bare string (with `$Name` interpolation). Interpolation only replaces `$` followed by letters, digits, or `_` (regex `\$[A-Za-z0-9_]+`). ### Escapes A backslash is literal, so Windows paths need no escaping (`C:\Pics`, `\\server\share`), except right before `"`, `'`, `$` or `n`: - `\"` and `\'` are quote characters inside a quoted value: `Text="say \"hi\""`. - `\$` is a literal dollar sign: `Text="Price \$5"`. - `\n` is a line break. - A run of backslashes before one of those is halved: `C:\\new` is the text `C:\new`, and a quoted path that ends in a backslash is written `"C:\Pics\\"`. Copy Script Command writes every value this way. Pyrite reads these escapes as plain text. ### Relative coordinates Drawing/geometry commands (`Draw`, `Select`, `Resize`, `Offset`, `CanvasSize`, ...) resolve each coordinate against the relevant maximum (canvas/layer width or height): - `""` -> `0` - `rnd` -> a random value in the range - `N%` -> that percentage of the maximum (e.g. `50%` -> half) - `-N` -> maximum minus N (measured from the far edge) - otherwise -> the literal number ```npss Draw 0% 0% 100% 100% # fill the whole layer Resize 50% 50% # halve the image ``` ### Points and curves Commands that take points (`TransformDistort`, `TransformCurve`, `DrawBezier`) write each one as `X,Y` with no space; each coordinate resolves as above. A cubic Bezier is given the way SVG's `C` path command and canvas `bezierCurveTo` give one: start, first control point, second control point, end, all absolute. `TransformDistort` takes the four corners clockwise from the top-left. A `TransformBendX` / `TransformBendY` amount is pixels, or `N%` of the object being bent; negative bows toward the left or the top. A transform works on the floating selection and leaves its result floating, so another transform or `PlaceSelection` can follow; with no selection it reshapes the whole active layer. ```npss TransformDistort 10%,0 90%,0 100%,100% 0,100% # a keystone TransformCurve 0,50% 33%,20% 67%,20% 100%,50% # an arch DrawBezier 10,80 40,20 160,20 190,80 PlaceBezier ``` ## Built-in statements These keywords are handled directly by the interpreter (they are not "commands" and never reach the host). `VAR` is a variable name (with or without `$`). | Statement | Syntax | Description | |---|---|---| | `Set` | `Set VAR=` | Assign a resolved value. RHS splits on **every** `=` and keeps field 2, so `Set a=b=c` stores `b`. | | `Increment` | `Increment VAR [amount]` | Add `amount` (default `1`) to a numeric `VAR` (blank counts as `0`). | | `Add` | `Add VAR ` | `VAR = VAR + number`. | | `Multiply` | `Multiply VAR ` | `VAR = VAR x number`. | | `Round` | `Round VAR` | Round `VAR` to the nearest integer. | | `Randomize` | `Randomize VAR ` | Set `VAR` to a random integer in `[min, max]`. | | `Append` | `Append VAR "text"` | Append `text` to `VAR` (quote-aware). | | `Prompt` | `Prompt VAR ["text"]` | Ask the user for a value. Cancel -> `""`. | | `PromptBoolean` | `PromptBoolean VAR ["text" ["yes" "no"]]` | OK -> `"True"`, otherwise `"False"`. | | `Push` | `Push VAR1 VAR2 ...` | Save the current value(s) of one or more variables (incl. system variables). | | `Pop` | `Pop VAR1 VAR2 ...` | Restore previously pushed value(s). Popping a name that was never pushed aborts. | `Push`/`Pop` are the idiomatic way to leave tool/color state as you found it: ```npss Push DrawingTool BackColor Set DrawingTool=Pencil Set BackColor=$ForeColor # ...draw... Pop DrawingTool BackColor ``` ## Blocks Block start/end matching is **prefix-based** on the trimmed, lowercased line, and blocks nest. A missing or mismatched end aborts the script. ### If ```npss If # runs only when the expression is true EndIf ``` ### Repeat Runs its body `N` times. `$LOOP_ITER` holds the current iteration (`0` to `N-1`) and is reset to `0` after the loop. ```npss Repeat 5 Alert "Iteration $LOOP_ITER" EndRepeat ``` ### ForEach Layer Iterates every layer, making each the active layer in turn, then restores the original active layer. Requires an open document. ```npss ForEach Layer Set ActiveLayerOpacity=50 EndForEach ``` ## Expressions (`If`) An `If` expression is ` `. The interpreter scans for the **first** operator it finds, in this order (most specific first): `!=`, `=`, `<=`, `<`, `>=`, `>`, ` like `, ` contains `. Because the first match wins, always surround operators with spaces to avoid surprises. Available operators: `=`, `!=`, `<`, `<=`, `>`, `>=`, `Like`, `Contains`. - `=` / `!=` for string equality (case-sensitive; literal `true`/`false` compared case-insensitively). - `<`, `<=`, `>`, `>=` for **numeric** comparison (blank -> `0`; non-numeric aborts). - `contains` for a case-sensitive substring test. - `like` for a VB-style pattern match: `*` (any run), `?` (one char), `#` (one digit), `[abc]` / `[a-z]` (character set), `[!abc]` (negated set). With **no** operator, the value is tested for truthiness: `"0"`, `"false"`, `"no"`, and `""` are false; everything else is true. ```npss If $Count > 10 Alert "Lots of items" EndIf If $Name like "IMG_####" Alert "Looks like a camera filename" EndIf ``` ## Filters and extensions A command whose first dot-segment is `Filter` or `Extension` (case-insensitive) invokes that filter/extension: - **No parameters** -> opens the filter's interactive dialog. - **Any parameters** -> runs with those parameters. Add `Silent=True` to force it to run without a dialog. Parameter keys may be nested (`Channels.Red=True`). ```npss Filter.Grayscale Silent=True Filter.Threshold Threshold=128 Channels.Red=True Channels.Green=False Channels.Blue=False ``` ## System variables Variables are read with `$Name` and written with `Set Name=value`. Names are **case-insensitive**. Reads resolve *system* variables first, then user variables, otherwise the empty string. Writing a **read-only** system variable shows an error but the script keeps running. ### Settable system variables | Variable | Allowed values | |---|---| | `ActiveLayer` | _(free-form value)_ | | `ActiveLayerBlendingMode` | `Normal`, `Dissolve`, `Keyed`, `Multiply`, `Screen`, `Overlay`, `HardLight`, `SoftLight`, `HardMix`, `ColorDodge`, `ColorBurn`, `Add`, `Subtract`, `Divide`, `Difference`, `Exclusion`, `LightenOnly`, `DarkenOnly`, `LighterColor`, `DarkerColor`, `BitwiseAND`, `BitwiseOR`, `BitwiseXOR`, `BitwiseXNOR`, `BitwiseOverIMPBase`, `BitwiseBaseIMPOver`, `HSLHue`, `HSLSaturation`, `HSLColor`, `HSLLightness`, `HSLRollHue`, `RGBRed`, `RGBGreen`, `RGBBlue`, `RGBAverage` | | `ActiveLayerColorMode` | `TrueColor`, `HighColor`, `WebSafe`, `Grayscale`, `Bitmap`, `Indexed`, `Palette` | | `ActiveLayerPalette` | _(free-form value)_ | | `ActiveLayerTransparencyMode` | `AlphaChannel`, `AlphaBit`, `TransparentColor`, `None` | | `ActiveLayerOpacity` | _(free-form value)_ | | `ActiveLayerName` | _(free-form value)_ | | `AirbrushShape` | `SquareNoise`, `RoundNoise`, `SquareSmooth`, `RoundSmooth` | | `AirbrushIntensity` | _(free-form value)_ | | `AnimationRepeat` | `True`, `False` | | `BrushShape` | `FilledSquare`, `FilledCircle`, `HollowSquare`, `HollowCircle`, `StraightCross`, `DiagonalCross`, `CaligraphyNE`, `CaligraphyNW`, `HorizontalLine`, `VerticalLine` | | `BrushConnected` | `True`, `False` | | `BucketFillMode` | `All`, `Contiguous`, `Bounded`, `Inverse` | | `BucketFillDirections` | `4`, `8` | | `BucketFillTolerance` | _(free-form value)_ | | `BucketFillTransparencyAware` | `True`, `False` | | `ColorCompositingMode` | `Blend`, `Overwrite` | | `ColorCyclingMode` | _(free-form value)_ | | `DocumentEnableAnimation` | `True`, `False` | | `DocumentFrameMode` | `True`, `False` | | `DocumentGlobalColorMode` | `True`, `False` | | `DrawingTool` | `Pointer`, `Move`, `RectangularSelect`, `Hand`, `FreeformSelect`, `Zoom`, `MagicWand`, `Gradient`, `Eyedropper`, `Fill`, `Pencil`, `Eraser`, `Airbrush`, `FilterTool`, `Line`, `Warp`, `BasicRectangle`, `RoundedRectangle`, `Ellipse`, `Polygon`, `Text`, `Bezier`, `Clone`, `TextureBrush`, `Brush`, `CustomBrush` | | `EyedropperScope` | `ActiveLayer`, `AllLayers`, `Screen` | | `FilterRepeat` | _(free-form value)_ | | `ForeColor` | _(free-form value)_ | | `BackColor` | _(free-form value)_ | | `Gradient` | _(free-form value)_ | | `GradientMode` | `Linear`, `Reflected`, `Radial` | | `LineWidth` | _(free-form value)_ | | `SelectionCompositingMode` | `Blend`, `Overwrite` | | `ShapeFillMode` | `BorderFill`, `BorderOnly`, `FillOnly` | | `Text` | _(free-form value)_ | | `TextAlignment` | `TopLeft`, `TopCenter`, `TopRight`, `MiddleLeft`, `MiddleCenter`, `MiddleRight`, `BottomLeft`, `BottomCenter`, `BottomRight` | | `TextBackground` | `Transparent`, `Solid`, `Rounded`, `AverageColor`, `Blur` | | `TextEffect` | `None`, `Outline`, `Sponge`, `Shadow`, `SimpleShadow`, `Glow`, `GradientH`, `GradientV`, `GradientR` | | `TextFont` | _(free-form value)_ | | `TextFontSize` | _(free-form value)_ | | `TextFontStyle` | `Bold`, `Italic`, `Underline`, `Strikeout`, `Bold Italic`, `Bold Underline`, `Bold Strikeout`, `Bold Italic Underline`, `Bold Italic Strikeout`, `Italic Underline`, `Italic Strikeout`, `Italic Underline Strikeout`, `Underline Strikeout`, `Bold Italic Underline Strikeout` | | `TransparencyEditingMode` | `Alpha`, `Keyed`, `Opaque` | | `ZoomLevel` | _(free-form value)_ | `Gradient` takes a built-in gradient's name (`"Foreground to Background"`, `"Foreground to Transparent"`) or a gradient library name (`.grdj` optional); `$Gradient` reads back the selected gradient's name. ### Read-only system variables `ActiveLayerHeight` | `ActiveLayerWidth` | `ActiveLayerDisplayName` | `ActiveLayerUniqueID` | `FileName` | `DocumentHeight` | `DocumentOpen` | `DocumentWidth` | `InstanceID` | `LayerCount` | `NOW` | `SelectionActive` | `SelectionX` | `SelectionY` | `SelectionHeight` | `SelectionWidth` | `MemoryUsedMB` | `MemoryBudgetMB` | `MemoryHeadroomMB` | `PendingUndoMB` | `MaterializedLayerCount` | `WindowWidth` | `WindowHeight` | `ActiveLayerLocked` | `ActiveLayerVisible` There is also the special loop variable `$LOOP_ITER` (see **Repeat**), and any number of user-defined variables you create with `Set`. `$WindowWidth` and `$WindowHeight` report the **last known** host window size, in the same units as `SetWindowSize` (see below). They are empty where the host cannot report a window size: browser mode, and on phones and tablets. ## Commands Every command below is what the in-app Script Editor's **Commands** menu inserts. `<...>` marks a value you supply. A command taking a fixed value set links to its list under [Value lists](#value-lists). Commands accept either positional arguments (`SetTool Pencil`) or `Key=Value` arguments where noted in the VB host; both forms are shown throughout the samples. ### Script Control | Command | Usage | Accepts | |---|---|---| | `Scope` | `Scope ` | `Selection`, `Layer`, `Document`, `Instance` | | `Abort` | `Abort` | | | `RequireVersion` | `RequireVersion "5.2.5"` | | | `ExecScript` | `ExecScript "C:\\Path\\To\\File"` | | | `ExecFilterMap` | `ExecFilterMap "Filter Map Name"` | | | `Sleep` | `Sleep 1000` | | | `LogMemory` | `LogMemory "Label goes here"` | | | `RequireHeadroom` | `RequireHeadroom 64` | | | `Alert` | `Alert "Message goes here"` | | | `Alert (complex)` | `Alert "Title goes here" "Message goes here"` | | | `Log` | `Log "Message goes here"` | | | `LogInfo` | `LogInfo "Message goes here"` | | | `LogWarning` | `LogWarning "Message goes here"` | | | `LogError` | `LogError "Message goes here"` | | | `Emit` | `Emit "Message goes here"` | | | `UpdateStatus` | `UpdateStatus "Message goes here"` | | | `ClearStatus` | `ClearStatus` | | | `PromptAction` | `PromptAction` | | | `ExplainTool` | `ExplainTool ` | [DrawingTool](#value-lists) | ### Variable Operations | Command | Usage | Accepts | |---|---|---| | `Push` | `Push ` | any variable name (see [System variables](#system-variables)) | | `Pop` | `Pop ` | any variable name (see [System variables](#system-variables)) | | `Increment` | `Increment ` | ` `, `LineWidth `, `ZoomLevel ` | | `Add` | `Add VariableName ` | | | `Multiply` | `Multiply VariableName ` | | | `Randomize` | `Randomize VariableName ` | | | `Round` | `Round VariableName` | | | `Append` | `Append VariableName "Text to add"` | | | `Prompt` | `Prompt VariableName` | | | `Prompt (with custom text)` | `Prompt VariableName "Custom prompt message"` | | | `PromptBoolean` | `PromptBoolean VariableName` | | | `PromptBoolean (with custom text)` | `PromptBoolean VariableName "Custom prompt message" "True text" "False text"` | | | `PromptColor` | `PromptColor VariableName` | | | `PromptFileOpen` | `PromptFileOpen VariableName` | | | `PromptFileSave` | `PromptFileSave VariableName` | | | `LoadSetting` | `LoadSetting VariableName` | | | `SaveSetting` | `SaveSetting VariableName` | | ### Undo and Steps | Command | Usage | Accepts | |---|---|---| | `BeginStep` | `BeginStep "My Step"` | | | `EndStep` | `EndStep` | | | `MarkClean` | `MarkClean` | | | `MarkDirty` | `MarkDirty` | | | `PurgeUndo` | `PurgeUndo` | | | `CommitAutosave` | `CommitAutosave` | | | `Undo` | `Undo` | | | `Redo` | `Redo` | | | `Refresh` | `Refresh` | | ### Loops and Conditionals | Command | Usage | Accepts | |---|---|---| | `If` | `If $variable="value" #Code goes hereEndIf` | | | `Repeat` | `Repeat 2 #Code goes here. Use $LOOP_ITER to get iteration count.EndRepeat` | | | `ForEach Layer` | `ForEach Layer #Code goes here. Active layer is set automatically.EndForEach` | | ### Layers | Command | Usage | Accepts | |---|---|---| | `AddLayer` | `AddLayer` | | | `AddLayer (named)` | `AddLayer ` | | | `DuplicateLayer (active)` | `DuplicateLayer` | | | `DuplicateLayer (specified)` | `DuplicateLayer ` | | | `DeleteLayer` | `DeleteLayer` | | | `RenameActiveLayer` | `RenameActiveLayer ` | | | `MoveLayer` | `MoveLayer ` | | | `AddLayerMask` | `AddLayerMask` | | | `MaskToLayer` | `MaskToLayer` | | | `DecomposeLayer` | `DecomposeLayer` | | | `ComposeLayer` | `ComposeLayer` | | | `DecomposeChannels` | `DecomposeChannels ` | `RGB`, `RGBW`, `RGBY`, `HSV`, `HSL`, `HSI`, `HWB`, `YUV`, `XYZ`, `Lab`, `HCL`, `Oklab`, `Oklch`, `HunterLAB`, `Yxy`, `LMS`, `Luv`, `CIECAM02Jab`, `CIECAM02Jch`, `CMY`, `CMYK`, `RYB`, `YIQ` | | `DecomposeChannels (advanced)` | `DecomposeChannels ` | | | `ComposeChannels` | `ComposeChannels ` | | | `ComposeChannels (advanced)` | `ComposeChannels ` | | | `ApplyLayerMask` | `ApplyLayerMask` | | | `RenderLayer` | `RenderLayer` | | | `FlattenImage` | `FlattenImage` | | | `MergeDown` | `MergeDown` | | | `MergeVisible` | `MergeVisible` | | | `FitToCanvas` | `FitToCanvas` | | | `LayerLocked` | `LayerLocked ` | `True`, `False` | | `LayerVisibility` | `LayerVisibility ` | `True`, `False` | | `SetGlobalColorMode` | `SetGlobalColorMode ` | `True`, `False` | ### Drawing | Command | Usage | Accepts | |---|---|---| | `BeginDraw` | `BeginDraw ` | | | `Draw (within Begin/End)` | `Draw ` | | | `Draw (single operation)` | `Draw ` | | | `EndDraw` | `EndDraw ` | | | `DrawBezier` | `DrawBezier , , , ,` | | | `SetCursor` | `SetCursor ` | [PaintCursor](#value-lists) | | `SetTool` | `SetTool ` | [DrawingTool](#value-lists) | | `ClearImage` | `ClearImage` | | | `ClearImage (color)` | `ClearImage ` | | | `ApplyFilter` | `ApplyFilter ` | [InternalFilter](#value-lists) | ### Image Operations | Command | Usage | Accepts | |---|---|---| | `CanvasSize` | `CanvasSize ` | | | `CanvasSize (advanced)` | `CanvasSize Width= Height= Alignment= FillColor=` | | | `CombineMask` | `CombineMask` | | | `Flip` | `Flip ` | `Horizontal`, `Vertical`, `Both` | | `InvertColors` | `InvertColors` | | | `ApplyLUT` | `ApplyLUT "LUT Name"` | | | `ApplyColorMatrix` | `ApplyColorMatrix 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1` | | | `ApplyGradientMap` | `ApplyGradientMap "Gradient Name"` | | | `ApplyGradientMap (reversed)` | `ApplyGradientMap "Gradient Name" True` | | | `ReduceColorDepth` | `ReduceColorDepth ` | `MedianCut`, `UniformRGB`, `UniformHSL`, `UniformLab`, `MostCommon`, `FirstX`, `Halftone`, `VGA`, `WinSystem`, `MacSystem`, `WebSafe`, `Grayscale`, `Monochrome` | | `ReduceColorDepth (colors)` | `ReduceColorDepth MedianCut ` | | | `SetAverageColor` | `SetAverageColor` | | | `SwapAlphaMask` | `SwapAlphaMask` | | | `MakeOpaque` | `MakeOpaque` | | | `Offset` | `Offset ` | | | `ShiftImage` | `ShiftImage ` | | | `PickChannels` | `PickChannels ` | | | `Resize` | `Resize ` | | | `Rotate` | `Rotate ` | | | `Rotate (advanced)` | `Rotate Angle= Expand= FillColor= InterpolationMode=` | | | `Skew` | `Skew ` | | | `Tile` | `Tile ` | | ### Animation | Command | Usage | Accepts | |---|---|---| | `AnimationNextFrame` | `AnimationNextFrame` | | | `AnimationPrevFrame` | `AnimationPrevFrame` | | | `AnimationPlay` | `AnimationPlay` | | | `AnimationPlayOnceAndWait` | `AnimationPlayOnceAndWait` | | | `AnimationPause` | `AnimationPause` | | | `AnimationReset` | `AnimationReset` | | | `AnimationGenerateFullFrames` | `AnimationGenerateFullFrames` | | | `SetAllFrameDelay` | `SetAllFrameDelay` | | | `SetAllFrameDisposal` | `SetAllFrameDisposal` | | | `AnimationSpin` | `AnimationSpin ` | | ### Selection and Object | Command | Usage | Accepts | |---|---|---| | `Cut` | `Cut` | | | `Copy` | `Copy` | | | `CopyActiveLayerToClipboard` | `CopyActiveLayerToClipboard` | | | `CopyMerged` | `CopyMerged` | | | `Paste` | `Paste` | | | `Delete` | `Delete` | | | `Select` | `Select ` | | | `SelectCopy` | `SelectCopy ` | | | `SelectAll` | `SelectAll` | | | `SelectAllContent` | `SelectAllContent` | | | `FindNext` | `FindNext` | | | `SelectionToLayer` | `SelectionToLayer` | | | `InvertSelection` | `InvertSelection` | | | `MoveObject` | `MoveObject ` | [ObjectMoveType](#value-lists) | | `RefineSelection` | `RefineSelection ` | [SelectionRefineType](#value-lists) | | `TransformDistort` | `TransformDistort , , , ,` | | | `TransformBendX` | `TransformBendX ` | | | `TransformBendY` | `TransformBendY ` | | | `TransformCurve` | `TransformCurve , , , ,` | | | `Deselect` | `Deselect` | | | `ClearSelection` | `ClearSelection` | | | `PlaceSelection` | `PlaceSelection` | | | `ClearBezier` | `ClearBezier` | | | `PlaceBezier` | `PlaceBezier` | | | `MeasureText` | `MeasureText TextWidth "Text goes here"` | | | `PlaceText` | `PlaceText` | | | `RasterizeText` | `RasterizeText` | | | `CropFit` | `CropFit ` | | | `CropToContent` | `CropToContent` | | | `CropToSelection` | `CropToSelection` | | ### Document | Command | Usage | Accepts | |---|---|---| | `NewDocument` | `NewDocument` | | | `NewDocument (template)` | `NewDocument ` | | | `OpenDocument` | `OpenDocument "C:\\Path\\to\\file"` | | | `OpenDocumentMRU` | `OpenDocumentMRU ` | | | `CloseDocument` | `CloseDocument` | | | `PasteAsNewImage` | `PasteAsNewImage` | | | `LoadSelection` | `LoadSelection "C:\\Path\\to\\file"` | | | `Save` | `Save` | | | `SaveCopy` | `SaveCopy "C:\\Path\\To\\File"` | | ### Window and Instance Control | Command | Usage | Accepts | |---|---|---| | `NewInstance` | `NewInstance` | | | `Exit` | `Exit` | | | `SetWindowSize` | `SetWindowSize 1280 800` | | | `MaximizeWindow` | `MaximizeWindow` | | | `SetColorSchemeMode` | `SetColorSchemeMode ` | `Toggle`, `Auto`, `Light`, `Dark` | | `CommitSettings` | `CommitSettings` | | | `CopySettingsToAllInstances` | `CopySettingsToAllInstances` | | | `ReloadSettings` | `ReloadSettings` | | | `SaveSettings` | `SaveSettings` | | | `CloseLayerList` | `CloseLayerList` | | | `OpenLayerList` | `OpenLayerList` | | | `CloseAllMenus` | `CloseAllMenus` | | | `DragCancel` | `DragCancel` | | | `LoadSwatches` | `LoadSwatches "PaletteName.npl"` | | | `LoadClassicPalette (by name)` | `LoadClassicPalette "Palette Name"` | | | `LoadClassicPalette (specified colors)` | `LoadClassicPalette "Red\|Orange\|Yellow\|Green\|Blue\|Indigo\|Violet"` | | ### Interactive UI | Command | Usage | Accepts | |---|---|---| | `UiFileNew` | `UiFileNew` | | | `UiFileOpen` | `UiFileOpen` | | | `UiFileOpenURL` | `UiFileOpenURL` | | | `UiFileSave` | `UiFileSave` | | | `UiFileSaveAs` | `UiFileSaveAs` | | | `UiFileDownload` | `UiFileDownload` | | | `UiFileExportViewer` | `UiFileExportViewer` | | | `UiFileExportSvg` | `UiFileExportSvg` | | | `UiFilePrint` | `UiFilePrint` | | | `UiFilePageSetup` | `UiFilePageSetup` | | | `UiEditProperties` | `UiEditProperties` | | | `UiClipFromScreenshot` | `UiClipFromScreenshot` | | | `UiClipFromScreenshotPaste` | `UiClipFromScreenshotPaste` | | | `UiPasteFromMonitor` | `UiPasteFromMonitor` | | | `UiImageCanvasSize` | `UiImageCanvasSize` | | | `UiImageResize` | `UiImageResize` | | | `UiImageRotateCustom` | `UiImageRotateCustom` | | | `UiImageSkew` | `UiImageSkew` | | | `UiImageOffset` | `UiImageOffset` | | | `UiImageTile` | `UiImageTile` | | | `UiImageCropAndFit` | `UiImageCropAndFit` | | | `UiImagePixelArtUpscale` | `UiImagePixelArtUpscale` | | | `UiImageGenerateIconVariants` | `UiImageGenerateIconVariants` | | | `UiImageSpritesheetToLayers` | `UiImageSpritesheetToLayers` | | | `UiImageLayersToSpritesheet` | `UiImageLayersToSpritesheet` | | | `UiActiveLayerProperties` | `UiActiveLayerProperties` | | | `UiRenameActiveLayer` | `UiRenameActiveLayer` | | | `UiSetAllLayerProperties` | `UiSetAllLayerProperties` | | | `UiColorLutEditor` | `UiColorLutEditor` | | | `UiColorMatrix` | `UiColorMatrix` | | | `UiColorGradientMap` | `UiColorGradientMap` | | | `UiColorPickChannels` | `UiColorPickChannels` | | | `UiColorCount` | `UiColorCount` | | | `UiColorIndexedPalette` | `UiColorIndexedPalette` | | | `UiColorReduceColorDepth` | `UiColorReduceColorDepth` | | | `UiColorSwatchesFromImage` | `UiColorSwatchesFromImage` | | | `UiPaletteEditProperties` | `UiPaletteEditProperties` | | | `UiSetAnimationSpeed` | `UiSetAnimationSpeed` | | | `UiSetAllFrameDelay` | `UiSetAllFrameDelay` | | | `UiSetAllFrameDisposal` | `UiSetAllFrameDisposal` | | | `UiAnimationSpin` | `UiAnimationSpin` | | | `UiAnimationCrossfade` | `UiAnimationCrossfade` | | | `UiFilterGallery` | `UiFilterGallery` | | | `UiScriptEditor` | `UiScriptEditor` | | | `UiFormatFont` | `UiFormatFont` | | | `UiPromptText` | `UiPromptText` | | | `UiToggleFullScreen` | `UiToggleFullScreen` | | | `UiDocumentRecovery` | `UiDocumentRecovery` | | | `UiCheckForUpdates` | `UiCheckForUpdates` | | | `UiShowReleaseNotes` | `UiShowReleaseNotes` | | | `UiHelpContents` | `UiHelpContents` | | | `UiHelpAbout` | `UiHelpAbout` | | | `UiFeedbackForm` | `UiFeedbackForm` | | | `UiShowConfigDialogSingle` | `UiShowConfigDialogSingle ` | | ### Window size `SetWindowSize ` resizes the app window, un-maximizing it first if it is maximized. `MaximizeWindow` maximizes it. The numbers are in **the same units the host stores in its `Window.Width` / `Window.Height` settings**, so a size you set is the size you will see recorded: | Host | Units | |---|---| | macOS / Linux / Windows (Avalonia) | device-independent pixels | | Linux / Windows (Photino) | physical device pixels | | Windows (WinUI) | physical device pixels | That means the same script produces a physically larger window on a high-DPI Windows or Linux machine than on a Mac. Use `$WindowWidth` / `$WindowHeight` to read the size back in the same units. Both commands report **"This command is not available on this platform."** where the window cannot be resized: a browser tab, phones and tablets, and the Pyrite desktop host. An installed PWA can usually resize itself. A size the platform refuses (below its minimum window size, say) reports the host's own message. ### Color scheme mode `SetColorSchemeMode Auto|Light|Dark|Toggle` sets the color scheme's Mode, the same setting as the Options dialog, and applies it to every open window. `Auto` follows the system. `Toggle` switches to the opposite of what is showing, reading `Auto` as the system's current light/dark setting, so two toggles come back to where they started. The value is saved even when the screen cannot change: the system has turned on high contrast, or the scheme has no light and dark pair. ## Value lists Canonical values for the enumerated parameters above. Values are matched **case-insensitively**, and many also accept **synonyms** (see below); the canonical names listed here always work. **DrawingTool** `Pointer` | `Move` | `RectangularSelect` | `Hand` | `FreeformSelect` | `Zoom` | `MagicWand` | `Gradient` | `Eyedropper` | `Fill` | `Pencil` | `Eraser` | `Airbrush` | `FilterTool` | `Line` | `Warp` | `BasicRectangle` | `RoundedRectangle` | `Ellipse` | `Polygon` | `Text` | `Bezier` | `Clone` | `TextureBrush` | `Brush` | `CustomBrush` **PaintCursor** `Default` | `Cross` | `Drag` | `HandFlat` | `HandDrag` | `Zoom` | `Unavailable` | `Move` | `Custom` **InternalFilter** `BlackAndWhite` | `Invert` | `Brighten` | `Highlight` | `Darken` | `Smoke` | `Diffuse` | `Blur` | `Emboss` | `Grayscale` | `Desaturate` | `ColorSwap` | `RedEyeRemoval` | `Sharpen` | `Wave` | `BaseRGB` | `Recolor` | `Noise` | `Speckle` | `Solarize` | `Posterize` | `TwoTone` | `GraphicPen` | `FrostedGlass` | `Rain` | `BitwiseAND` | `BitwiseOR` | `BitwiseXOR` | `BitwiseEQV` | `BitwiseIMP1` | `BitwiseIMP2` | `Plaid` | `SetTransparentColor` | `ColorToAlpha` | `MaskColorize` | `Addition` | `Subtraction` | `Multiplication` | `Opacify` **ObjectMoveType** `Left` | `Right` | `Top` | `Bottom` | `Center` | `CenterHorizontal` | `CenterVertical` | `OriginCanvas` | `OriginLayer` | `OriginViewport` | `PushLeft` | `PushRight` | `PushAbove` | `PushBelow` **SelectionRefineType** `FillWidth` | `FillHeight` | `FillLeft` | `FillRight` | `FillUp` | `FillDown` | `Expand` | `Shrink` | `Feather` **ContentAlignment** `TopLeft` | `TopCenter` | `TopRight` | `MiddleLeft` | `MiddleCenter` | `MiddleRight` | `BottomLeft` | `BottomCenter` | `BottomRight` **CropFitTarget** `Selection` | `ActiveLayer` | `AllLayers` | `Canvas` **CropFitSource** `Selection` | `Content` | `CanvasBoundsCropOnly` | `CanvasBoundsFit` | `AllLayerContent` | `AllLayerBounds` **ActiveLayerBlendingMode** `Normal` | `Dissolve` | `Keyed` | `Multiply` | `Screen` | `Overlay` | `HardLight` | `SoftLight` | `HardMix` | `ColorDodge` | `ColorBurn` | `Add` | `Subtract` | `Divide` | `Difference` | `Exclusion` | `LightenOnly` | `DarkenOnly` | `LighterColor` | `DarkerColor` | `BitwiseAND` | `BitwiseOR` | `BitwiseXOR` | `BitwiseXNOR` | `BitwiseOverIMPBase` | `BitwiseBaseIMPOver` | `HSLHue` | `HSLSaturation` | `HSLColor` | `HSLLightness` | `HSLRollHue` | `RGBRed` | `RGBGreen` | `RGBBlue` | `RGBAverage` **ActiveLayerColorMode** `TrueColor` | `HighColor` | `WebSafe` | `Grayscale` | `Bitmap` | `Indexed` | `Palette` **ActiveLayerTransparencyMode** `AlphaChannel` | `AlphaBit` | `TransparentColor` | `None` **AirbrushShape** `SquareNoise` | `RoundNoise` | `SquareSmooth` | `RoundSmooth` **BrushShape** `FilledSquare` | `FilledCircle` | `HollowSquare` | `HollowCircle` | `StraightCross` | `DiagonalCross` | `CaligraphyNE` | `CaligraphyNW` | `HorizontalLine` | `VerticalLine` **BucketFillMode** `All` | `Contiguous` | `Bounded` | `Inverse` **EyedropperScope** `ActiveLayer` | `AllLayers` | `Screen` **GradientMode** `Linear` | `Reflected` | `Radial` **ShapeFillMode** `BorderFill` | `BorderOnly` | `FillOnly` **TextBackground** `Transparent` | `Solid` | `Rounded` | `AverageColor` | `Blur` **TextEffect** `None` | `Outline` | `Sponge` | `Shadow` | `SimpleShadow` | `Glow` | `GradientH` | `GradientV` | `GradientR` **TextFontStyle** `Bold` | `Italic` | `Underline` | `Strikeout` | `Bold Italic` | `Bold Underline` | `Bold Strikeout` | `Bold Italic Underline` | `Bold Italic Strikeout` | `Italic Underline` | `Italic Strikeout` | `Italic Underline Strikeout` | `Underline Strikeout` | `Bold Italic Underline Strikeout` **TransparencyEditingMode** `Alpha` | `Keyed` | `Opaque` ### Synonyms Alternate spellings accepted on input (case-insensitive), grouped by the canonical value they resolve to. Prefer canonical names when generating scripts; these are for reading existing scripts and for accepting looser input. - **DrawingTool**: `tbairbrush` -> **Airbrush** | `rectangle`, `tbbasicrectangle` -> **BasicRectangle** | `tbbezier` -> **Bezier** | `tbbrush` -> **Brush** | `tbclone` -> **Clone** | `tbcustombrush` -> **CustomBrush** | `tbellipse` -> **Ellipse** | `tberaser` -> **Eraser** | `tbeyedropper` -> **Eyedropper** | `bucketfill`, `tbbucketfill`, `tbfill` -> **Fill** | `tbfiltertool` -> **FilterTool** | `tbfreeformselect` -> **FreeformSelect** | `tbgradient` -> **Gradient** | `tbhand` -> **Hand** | `tbline` -> **Line** | `tbmagicwand` -> **MagicWand** | `tbmove` -> **Move** | `tbpencil` -> **Pencil** | `tbpointer` -> **Pointer** | `tbpolygon` -> **Polygon** | `tbrectangularselect` -> **RectangularSelect** | `tbroundedrectangle` -> **RoundedRectangle** | `tbtext` -> **Text** | `tbtexturebrush` -> **TextureBrush** | `tbwarp` -> **Warp** | `tbzoom` -> **Zoom** - **AirbrushShape**: `round` -> **RoundNoise** | `smoothcircle` -> **RoundSmooth** | `smoothsquare`, `square`, `squaresmooth` -> **SquareNoise** - **LayerBlendingMode**: `alpha` -> **Normal** - **LayerColorMode**: `argb`, `full` -> **TrueColor** - **CropFitSource**: `selectionbounds` -> **Selection** - **TextEffect**: `gradientradial` -> **GradientR** ## Command index `Abort` | `Add` | `AddLayer` | `AddLayerMask` | `Alert` | `AnimationGenerateFullFrames` | `AnimationNextFrame` | `AnimationPause` | `AnimationPlay` | `AnimationPlayOnceAndWait` | `AnimationPrevFrame` | `AnimationReset` | `AnimationSpin` | `Append` | `ApplyColorMatrix` | `ApplyFilter` | `ApplyGradientMap` | `ApplyLayerMask` | `ApplyLUT` | `BeginDraw` | `BeginStep` | `CanvasSize` | `ClearBezier` | `ClearImage` | `ClearSelection` | `ClearStatus` | `CloseAllMenus` | `CloseDocument` | `CloseLayerList` | `CombineMask` | `CommitAutosave` | `CommitSettings` | `ComposeChannels` | `ComposeLayer` | `Copy` | `CopyActiveLayerToClipboard` | `CopyMerged` | `CopySettingsToAllInstances` | `CropFit` | `CropToContent` | `CropToSelection` | `Cut` | `DecomposeChannels` | `DecomposeLayer` | `Delete` | `DeleteLayer` | `Deselect` | `DragCancel` | `Draw` | `DrawBezier` | `DuplicateLayer` | `Emit` | `EndDraw` | `EndStep` | `ExecFilterMap` | `ExecScript` | `Exit` | `ExplainTool` | `FindNext` | `FitToCanvas` | `FlattenImage` | `Flip` | `ForEach` | `If` | `Increment` | `InvertColors` | `InvertSelection` | `LayerLocked` | `LayerVisibility` | `LoadClassicPalette` | `LoadSelection` | `LoadSetting` | `LoadSwatches` | `Log` | `LogError` | `LogInfo` | `LogMemory` | `LogWarning` | `MakeOpaque` | `MarkClean` | `MarkDirty` | `MaskToLayer` | `MaximizeWindow` | `MeasureText` | `MergeDown` | `MergeVisible` | `MoveLayer` | `MoveObject` | `Multiply` | `NewDocument` | `NewInstance` | `Offset` | `OpenDocument` | `OpenDocumentMRU` | `OpenLayerList` | `Paste` | `PasteAsNewImage` | `PickChannels` | `PlaceBezier` | `PlaceSelection` | `PlaceText` | `Pop` | `Prompt` | `PromptAction` | `PromptBoolean` | `PromptColor` | `PromptFileOpen` | `PromptFileSave` | `PurgeUndo` | `Push` | `Randomize` | `RasterizeText` | `Redo` | `ReduceColorDepth` | `RefineSelection` | `Refresh` | `ReloadSettings` | `RenameActiveLayer` | `RenderLayer` | `Repeat` | `RequireHeadroom` | `RequireVersion` | `Resize` | `Rotate` | `Round` | `Save` | `SaveCopy` | `SaveSetting` | `SaveSettings` | `Scope` | `Select` | `SelectAll` | `SelectAllContent` | `SelectCopy` | `SelectionToLayer` | `SetAllFrameDelay` | `SetAllFrameDisposal` | `SetAverageColor` | `SetColorSchemeMode` | `SetCursor` | `SetGlobalColorMode` | `SetTool` | `SetWindowSize` | `ShiftImage` | `Skew` | `Sleep` | `SwapAlphaMask` | `Tile` | `TransformBendX` | `TransformBendY` | `TransformCurve` | `TransformDistort` | `UiActiveLayerProperties` | `UiAnimationCrossfade` | `UiAnimationSpin` | `UiCheckForUpdates` | `UiClipFromScreenshot` | `UiClipFromScreenshotPaste` | `UiColorCount` | `UiColorGradientMap` | `UiColorIndexedPalette` | `UiColorLutEditor` | `UiColorMatrix` | `UiColorPickChannels` | `UiColorReduceColorDepth` | `UiColorSwatchesFromImage` | `UiDocumentRecovery` | `UiEditProperties` | `UiFeedbackForm` | `UiFileDownload` | `UiFileExportSvg` | `UiFileExportViewer` | `UiFileNew` | `UiFileOpen` | `UiFileOpenURL` | `UiFilePageSetup` | `UiFilePrint` | `UiFileSave` | `UiFileSaveAs` | `UiFilterGallery` | `UiFormatFont` | `UiHelpAbout` | `UiHelpContents` | `UiImageCanvasSize` | `UiImageCropAndFit` | `UiImageGenerateIconVariants` | `UiImageLayersToSpritesheet` | `UiImageOffset` | `UiImagePixelArtUpscale` | `UiImageResize` | `UiImageRotateCustom` | `UiImageSkew` | `UiImageSpritesheetToLayers` | `UiImageTile` | `UiPaletteEditProperties` | `UiPasteFromMonitor` | `UiPromptText` | `UiRenameActiveLayer` | `UiScriptEditor` | `UiSetAllFrameDelay` | `UiSetAllFrameDisposal` | `UiSetAllLayerProperties` | `UiSetAnimationSpeed` | `UiShowConfigDialogSingle` | `UiShowReleaseNotes` | `UiToggleFullScreen` | `Undo` | `UpdateStatus` ## Worked examples ### Prompt and branch ```npss Prompt VarName "Enter Yes or something else" If $VarName = "Yes" Alert "You entered Yes" EndIf If $VarName = "" Alert "You canceled the dialog" EndIf ``` ### Accumulate in a loop ```npss Set Total=0 Repeat 5 Add Total $LOOP_ITER EndRepeat Alert "Sum of 0..4 = $Total" ``` ### Dim every layer, restoring state ```npss Scope Document ForEach Layer Set ActiveLayerOpacity=50 EndForEach ``` ### A self-contained drawing step ```npss Scope Document Push DrawingTool ShapeFillMode LineWidth Set DrawingTool=Rectangle Set ShapeFillMode=FillOnly Set LineWidth=1 BeginStep "Fill quarter" Push BackColor Set BackColor=$ForeColor Draw 0% 0% 50% 50% Pop BackColor EndStep Pop DrawingTool ShapeFillMode LineWidth ```