Command Line Example

Author: Wayne Rasband (wsr at
History: 2002/12/16: First version
2004/05/26: Calculates mean area
Requires: ImageJ 1.33l or later
Installation: Download to the plugins folder and compile it using the Plugin/Compile and Run command.

This plugin is obsolete. ImageJ 1.36 and later can directly run plugins and macros from the command line using the -run, -macro, -batch and -eval options described at the beginning of

This example program/plugin shows one way to use ImageJ from the command line. It opens an image, converts it to binary, runs the particle analyzer, calculates mean area, and writes the results to a file named "results.txt". Use the Plugins/Compile and Run command to compile and test it. To run it from the command line, use:

    java -cp ij.jar:. analyze blobs.tif > results.txt (Unix)
    java -cp ij.jar;. analyze blobs.tif > results.txt (Windows)

The files ij.jar, analyze.class and blobs.tif are assumed to be in the current directory. The plugins directory must also be in the current directory if any plugins are called. Alternatively, define the "plugins.dir" property so it points to the directory that contains the plugins directory, as in these examples:

    java -Dplugins.dir=/usr/local/ImageJ -cp /usr/local/ij.jar:. analyze blobs.tif > results.txt (Unix)
    java -Dplugins.dir=C:\ImageJ -cp C:\ImageJ\ij.jar;. analyze blobs.tif > results.txt (Windows)

|Plugins | Home |