testing Groovy - ImageJ

There is a new ImageJ plugin that allows you to fo scripting with Groovy.

ij-Groovy
http://ij-plugins.sourceforge.net/plugins/groovy/tutorials.html#RecordingScripts

so I became interested in how it would be like using it. GroovyConsole seems to be an handy Editor, so instead of installing the plugin to ImageJ, I made a trial to use ImageJ as a libray, accessing directly from Groovy. It was pretty simple to do this task, but I note down how I installed mainly because I will forget what I did.

1. Go to the groovy site, and download the zipped binary.
http://groovy.codehaus.org/Download

I downloaded Groovy 1.7.8 and unzipped the folder groovy-1.7.8 under C:\dev.

2. Add path C:\dev\groovy-1.7.8 as a new environmental variable “GROOVY_HOME” .

3. Add path %GROOVY_HOME%\bin to the system path.

4. Launch the console by clicking %GROOVY_HOME%\bin\GroovyConsole.bat

5. set path to ij.jar by [Script > Add Jar to Classpath]

Following is the code I tested, which worked fine without opening ImageJ main menu.

import ij.*

imp = IJ.openImage("http://rsb.info.nih.gov/ij/images/gel.gif");
IJ.log(imp.getDimensions()[0].toString());
imp.show();

Running this code, an image window pops sup and also the width of the image is printed in the output field of the console. IJ.log command which normally should print out the string argument in log window seems to be diverted to the console output.
Interpreter runs with a speed comparable to Javascript and Jython running with ImageJ jar.

Good point about this console is that referencing to a jar file could be easily be done, by [scripts > add jar to classpath] This affords a good simple interface for test assembling several Java libraries.