ScriptingQR for this page
ImageJ allows you to write scripts in several different languages.
- 1 Getting started
- 2 Supported languages
- 3 Script parameters
- 4 Using an interpreter
- 5 Using the script editor
- 6 Creating scripts and using "refresh scripts"
- Press the [ key to open the Script Editor.
- Optionally, choose a template from the Templates menu to get you started.
- Otherwise, choose your language from the Language menu.
- Grab code snippets for common tasks from the Scripting toolbox.
- See Scripting comparisons for a side-by-side comparison of scripting languages.
- See Category:Scripting for a list of all scripting-related pages on this wiki.
ImageJ's Script Editor supports the following languages:
Additionally, these languages can be installed via update sites:
There is a universal
@parameter notation available across all scripts for declaring inputs and outputs. This approach is preferred to using ImageJ 1.x
GenericDialog because it is totally agnostic to the user interface, allowing such scripts to run in a variety of contexts.
See the script parameters page for details.
Using an interpreter
All scripting languages use the same basic interpreter, with the following common features.
General key bindings
- up arrow: bring the previously typed command.
- down arrow: bring the next typed command.
- enter or return: execute the contents of the prompt.
Multiline editing and keybindings
You can enlarge the prompt by dragging the middle bar.
- ⇧ Shift+⌅ Enter: create a new line within the prompt.
- ⇧ Shift+↑: move to the line above within the prompt.
- ⇧ Shift+↓: move to the line below within the prompt.
Selecting and executing text from the screen
On selecting text, a popup offers to:
- save to a new file
Using the script editor
You can create, edit and run scripts using Fiji's script editor. For details, please see the Script Editor documentation.
Creating scripts and using "refresh scripts"
On startup, ImageJ will run all "refresh scripts" plugins, one for each supported language. This will result in all scripts present within the plugins folders to be added to the menus.
To run a script, just select it from the plugins menus.
If you edit a script that is already placed in the menus, you don't need to do anything else: just save the text file and run it again by selecting it from the menus.
If you add a new script and ImageJ is running, just go to Plugins - Scripting and run the appropriate Refresh * Scripts for the language.
Running scripts in headless mode
See the Headless page for instructions on executing scripts headlessly.