Author: Wayne Rasband (wsr at nih.gov) History: 2005/06/03: First version
2006/05/27: Updated to work with ImageJ 1.37h
Requires: ImageJ 1.37h or later
Source: Contained in macro-runner.zip Installation: Download macro-runner.zip and extract the MacroRunner folder. Description: RunMacro is a Java program (not a plugin) that runs an ImageJ macro from the command line with no GUI. It uses the IJ.runMacroFile(path, arg) method that was added in ImageJ 1.33c to run a macro and to pass it a single string argument. ImageJ 1.37h and later can also runs macros from the command line using the -batch option documented at the beginning of ImageJ.java.
To compile:
javac -classpath ij.jar RunMacro.java
To run "analyze.txt", passing it the argument "blobs.tif":
java -cp ij.jar:. RunMacro analyze.txt Blobs.tif (Unix)
java -cp ij.jar;. RunMacro analyze.txt Blobs.tif (Windows)You can also run this macro by running ImageJ with the -batch command line option:
java -jar ij.jar -batch analyze blobs.tif
Use I/O redirection to save macro output in a file:
java -jar ij.jar -batch analyze blobs.tif>results.txt
Four example command line macros are in MacroRunner folder:
table.txt: Generates a sine/cosine table
analyze.txt: Runs the particle analyzer on an image
process.txt: Analyzes all the tiff images in a folder
count.txt: Counts the number of lines in a text file
OS X and Linux users can create an alias something like this
alias run 'java -cp /usr/local/ij/ij.jar:/usr/local/ij RunMacro'that enables macros to be run by typing something likerun analyze blobs.tif