Login  Register

Re: JavaScript batch mode doesn't have open images?

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jun 24, 2010; 6:33pm
URL: http://imagej.273.s1.nabble.com/JavaScript-batch-mode-doesn-t-have-open-images-tp3687827p3687828.html

On Jun 21, 2010, at 4:47 PM, Adam Goode wrote:

> Hi,
>
> I am converting some old macros to JavaScript to use with the -batch
> command line. The macro contains some run(...) commands that call other
> plugins that open multiple windows. With the old macro system, in batch
> mode, I could close images and work with the active image, but with
> JavaScript, there are never any images open. IJ.getImage() produces an
> error.
>
> It looks like the Interpreter class contains a mechanism for holding
> onto images in batch mode (the imageTable). Can this be made to work
> when executing JavaScript?

This bug is fixed in the 1.44d7 daily build. Methods that open an image, like IJ.getImage(), now work as expected in "-batch" command line ".js" scripts. The image is not displayed but it can be retrieved by calling WindowManager.getCurrentImage(). ImageJ commands that display multiple images, such as IJ.run(imp, "Split Channels", ""), also work.

-wayne