Hide
IJ2 is out
 Sec. 17: Scripting Up Part III: Extending IJ Part IV: IJ User Interface 

18 Running ImageJ from the Command Line

ImageJ was devised as a desktop application. It can, however, run without a graphics environment (headless mode) by adding a special library (headless.jar) to the ij.jar classpath that overrides key ImageJ classes to work better headlessly. As described on the Fiji website, this strategy is implemented in Fiji↑ through the --headless command line flag (see also Running ImageJ in headless mode and Using Cluster for Image Processing with IJ). Headless operations are simplified in ImageJ2↑.
ImageJ recognizes the following command line options:
"file-name" Opens a file. Examples:
blobs.tif
/Users/wayne/images/blobs.tif
e81*.tif
-ijpathpath Specifies the path to the directory containing the plugins directory. Example:
-ijpath /Applications/ImageJ
-port Specifies the port ImageJ uses to determine if another instance is running. Examples:
-port1 (use default port address + 1)
-port2 (use default port address + 2)
-port0 (do not check for another instance (OtherInstance)
-macropath[arg] Runs a macro or script, passing it an optional argument, which can be retrieved using getArgument(). Examples:
-macro analyze.ijm
-macro analyze /Users/wayne/images/stack1
-batchpath[arg] Runs a macro or script in batch mode (no GUI), passing it an optional argument. ImageJ exits when the macro finishes.
-eval"macrocode" Evaluates macro code. Examples:
-eval "print('Hello, world');"
-eval "return getVersion();"
-runcommand Runs an ImageJ menu command. Example:
-run "About ImageJ..."
-debug Runs ImageJ in debug mode.
 Sec. 17: Scripting Up Part III: Extending IJ Part IV: IJ User Interface