|
Table of Contents
|
NPS Script ReferenceNPS Image Editor has scripting support to help automate certain tasks. Scripts can be run in several ways:
Scripting is currently not complete (but this is a work in progress). Below you can find a reference for the current set of supported commands. SyntaxThe general syntax of a script line is:
Parameters and values that consist of strings with multiple words must be quoted. Quotes are optional for single-word strings.
Variables start with a $ and will be interpreted in most commands.
While not recommended, it is also possible to use the variable form in variable-specific keywords like
Lines beginning with # are comments and will not be interpreted. Blank lines will also be ignored. Scope
Validates the scope of a script. Valid values are: A scope of
The default scope is
If the conditions of the scope are not met – for example, if you have a scope of Variables
Variables start with a $ character and can contain letters, numbers, or underscores. Note, however, that commands taking a variable
name usually do not need the $ character in front of the variable. For example in the expression System vs. User variables
System variables are bound to various data in NPS or the document. For example User variables just hold values. Any variable that is not a system variable will be considered a user variable. Push and Pop
You can
OperationsTODO Undo stepsCalling script commands will perform default behaviors associated with them. For example, placing a selection will cause a "selection placed" action to be added to the undo history.
If you are performing multiple actions in a row, they will create individual undo steps which can lead to a sub-optimal user experience.
You can group actions with
Note that this is not always possible; if the action is already creating multi-undo steps like this, you can't nest them. An error will be displayed if this is not possible.
Be sure to call Calling other scripts
You can call one script from another using the
Command referenceThe following commands are available. Commands have 0 or more parameters. Parameters are specified after the command with a space. For example: AbortAborts the currently-running script AddLayerAdds a new empty layer to the image AddLayerMaskAdds a new empty layer mask to the image. AlertDisplays an alert message. Parameter 1 (required): The message text. Enclose the message in quotes. Parameter 2 (optional): The secondary message text. Enclose the message in quotes. AnimationNextFrameAdvances the animation forwards by one frame. AnimationPrevFrameAdvances the animation backwards by one frame. AnimationPlayStarts playing the animation asynchronously from the current position. AnimationPlayOnceAndWaitPlays the animation once from start to finish, waiting until completion to run the next script command. AnimationPausePauses the animation. AnimationResetResets the animation to the beginning. AnimationGenerateFullFramesGenerates full frames for the animation ("unoptimize"). AnimationSpinGenerates frames to animate the current layer. Parameter 1 (required): The total number of frames (minimum 2, maximum 360) Parameter 2 (required): The total duration of the animation Parameter 3 (required): The background color for areas outside of the frame when it has been rotated Parameter 4 (required): Interpolation mode Parameter 5 (required): True for counterclockwise rotation, False for clockwise rotation ApplyFilterApplies the specified internal filter (same ones used for the Filter Tool) BeginDrawStarts a drawing operation. This is the equivalent of clicking the mouse down. BeginStepBegins a multi-undo step which will allow all subsequent commands to be undone as a single operation. Must be closed with Parameter 1 (required): The name of the undo step, as it will appear in undo history. CanvasSizeSets the canvas size. ClearBezierClears the currently-active Bezier curve ClearImageClears the contents of the active layer ClearSelectionDeletes the active selection without placing it ClearStatusClears the current status in the status bar CloseDocumentCloses the currently-open document CloseLayerListHides the layer list CommitAutosaveCommits auto-save data after an important operation CommitSettingsSaves the current configuration to the backing store CopyCopies the active selection to the clipboard CopyActiveLayerToClipboardCopies the image data of the active layer to the clipboard CopySettingsToAllInstancesApplies the current settings across all running instances CropFitCrops or fits the image. Parameter 1 (required): The crop/fit target. Valid values are:
Parameter 2 (required): The crop/fit source mode. Valid values are:
CropToContentCrops the selection or image to its content CropToSelectionCrops the image to the active selection CutCuts the active selection DeleteDeletes the active object DeselectRemoves the active selection. If the selection has moved, this restores the image to the point prior to the selection's placing. DeleteLayerRemoves the layer from the document DeselectRemoves the selection without placing it. The actual behavior depends on whether the selection came from the current document or an external source (like the clipboard). DragCancelCancels a file drag operation DrawPerforms a drawing operation
If only 2 parameters (X and Y) are specified, this acts as the intermediate step between If 4 parameters are specified, this performs a complete set of drawing steps – equivalent to clicking the mouse down at X1,Y1 and releasing it at X2,Y2. DuplicateLayerCreates a copy of the active layer EmitEvaluates the specified value (see: Setting values) EndDrawCompletes the current drawing operation. This is the equivalent of releasing the mouse. EndStepEnds a multi-undo step started with ExitExits the program ExplainToolOutputs a description of the specified tool FindNextFinds the next occurrence of the selected pixels within the image FitToCanvasFits the active layer to the canvas FlattenImageFlattens the image InvertSelectionInverts the selection LayerLockedLocks or unlocks the active layer LayerVisibilityToggles visibility of the active layer LoadSwatchesLoads the specified swatch palette LoadClassicPaletteLoads a classic color palette (bottom of the screen) LoadSelectionCreates a selection from the specified file path LoadSettingLoads a specific configuration setting. Log, LogInfo, LogWarning, LogErrorLogs the specified text to debug Parameter 1 (required): The message to output to the log. Enclose in quotes. MarkCleanMarks the image clean (unmodified) MarkDirtyMarks the image dirty (modified). This will prompt the user to save when closing. MaskToLayerConverts the current layer's mask to an editable layer MeasureTextCalculates the dimensions of a text string MergeDownMerges the active layer with the one below it MergeVisibleMerges visible layers MoveObjectMoves the selection, text, or bezier to the specified location Parameter 1 (required): The selection move type. Valid values are:
NewDocumentCreates a new document. Prompts to save the existing one if open. Parameter 1 (optional): The document template. If not specified, the default template is used. Valid templates are:
NewInstanceLaunches a new NPS Image Editor window. Note that the current script will continue executing in the window it was started from. OpenDocumentOpens the specified file. Parameter 1 (required): The path to the file to open OpenDocumentMRUOpens the specified Most Recently Used file Parameter 1 (required): The path to the file to open OpenLayerListShows the layer list PastePastes from the clipboard PasteAsNewImagePastes from the clipboard into a new document in the current window PlaceBezierPlaces the active Bezier curve PlaceSelectionPlaces the selection PlaceTextPlaces the text PromptActionPrompts to run a single script action PromptColorPrompts to select a color and stores the color expression to a variable PromptFileOpenPrompts to open an existing file for loading and stores the path to a variable PromptFileSavePrompts to open a new or existing file for saving and stores the path to a variable PurgeUndoClears all undo steps up to this point RasterizeTextConverts the current text to an image selection, allowing it to be modified like an image RefineSelectionRefines the selection, only possible when it has not moved and did not come from an external source Parameter 1 (required): The selection refine type. Valid values are:
RedoRedoes the last-undone action RefreshRefreshes the current image data. Useful for long-running operations to show visible progress. ReloadSettingsReapplies current saved settings to the current instance of NPS RenameActiveLayerRenames the active layer ResizeResizes the active layer SaveSaves the document interactively SaveCopySaves a copy of the document to the specified path. File format will automatically be determined based on the file extension. SaveSettingSaves a specific configuration value SaveSettingsSaves the settings for the current instance of NPS SelectCreates a selection. This command takes 4 parameters for each of the dimensions (X, Y, Width, Height). Parameters can be specified as absolute pixel values or relative percentage values. SelectAllSelects all pixels in the active layer SelectAllContentSelects all content, excluding empty regions, in the active layer SelectionToLayerConverts the selection to a new layer SelectCopyCreates a selection without removing it from the active layer. Parameters are the same as the SetAllFrameDelaySets the frame delay for all frames Parameter 1 (required): The frame delay, in milliseconds. SetAllFrameDisposalSets the frame disposal method for all frames Parameter 1 (required): The frame disposal mode, in milliseconds. Valid values are: Default, Combine, Background, Previous SetCursorSets the drawing cursor SetGlobalColorModeSets the global color mode of the image Parameter 1 (required): True to enable global color mode, False to disable global color mode (each layer has its own color mode). SetToolSets the drawing tool SleepWaits for the specified number of milliseconds before continuing. UndoUndoes the last action UpdateStatusUpdates the status bar during an operation UI script commandsThese are interactive UI actions designed to be launched from custom menus or buttons. UiActiveLayerPropertiesUiAnimationSpinUiClipFromScreenshotUiClipFromScreenshotPasteUiFileNewUiFileOpenUiFileOpenURLUiFileSaveUiFileSaveAsUiFormatFontUiHelpContentsUiImageCanvasSizeUiImageGenerateIconVariantsUiUmageOffsetUiImageResizeUiImageRotateCustomUiImageSkewUiPaletteEditPropertiesUiPasteFromMonitorUiPromptTextUiRenameActiveLayerUiSetAllFrameDelayUiSetAllFrameDisposalUiSetAnimationSpeedUiShowConfigDialogSingleDisplays a configuration dialog for a single page UiShowReleaseNotesUiToggleFullscreenSetting system variables
The
The following values can be set: ActiveLayerSets the active layer given its index (the background layer is 0). ActiveLayerBlendingModeSets the active layer's blending mode.
Valid values are:
ActiveLayerColorModeSets the active layer's color mode.
Valid values are:
ActiveLayerTransparencyModeSets the active layer's transparency mode.
Valid values are:
ActiveLayerOpacitySets the active layer's global opacity. 0 is fully transparent and 255 is fully opaque. ActiveLayerNameSets the active layer's name. AirbrushShapeSets the Airbrush tool's shape.
Valid values are:
AirbrushIntensitySets the Airbrush tool's intensity. AnimationRepeatSets the animation repeat mode.
Valid values are:
BrushShapeSets the Brush tool's shape.
Valid values are:
BucketFillModeSets how the Bucket Fill tool chooses pixels.
Valid values are:
BucketFillDirectionsSets the number of directions the Bucket Fill tool will search in.
Valid values are:
BucketFillToleranceSets the tolerance of the Bucket Fill tool. A tolerance of 0 requires colors to match exactly. BucketFillTransparencyAwareSets whether or not the Bucket Fill tool is aware of transparent pixels in the image.
Valid values are:
ColorCompositingModeSets how colors are blended when drawing with semi-transparent colors.
Valid values are:
ColorCyclingModeSets the color cycling mode. DocumentEnableAnimationSets whether the current document supports animation.
Valid values are:
DocumentFrameModeSets whether layers should be displayed as independent frames or blended layers.
Valid values are:
DocumentGlobalColorModeSets whether all layers use the same color mode (and palette, if applicable).
Valid values are:
DrawingToolSets the current drawing tool.
Valid values are:
EyedropperScopeSets the scope of the Eyedropper tool.
Valid values are:
ForeColorSets the foreground color to use for drawing. BackColorSets the background color to use for drawing. LineWidthSets the line width (in pixels) to use for drawing. SelectionCompositingModeSets how the selection handles transparent pixels.
Valid values are:
ShapeFillModeSets the fill mode for various shape tools.
Valid values are:
TextSets the text in the Text tool. TextAlignmentSets the alignment of text within the Text tool.
Valid values are:
TextBackgroundSets the background of the Text tool.
Valid values are:
TextEffectSets the text effect for the Text tool.
Valid values are:
TextFontSets the font family used by the Text tool. TextFontSizeSets the font size used by the Text tool. TextFontStyleSets the value of TextFontStyle
Valid values are:
TransparencyEditingModeSets the behavior of empty regions of the image, such as those exposed by moving a selection or expanding the canvas.
Valid values are:
ZoomLevelSets the current zoom level. |