Hi,
I have this macro: var z = getImageID(); print(z); selectImage(z); run("Duplicate...", "title=item2"); var z2 = getImageID(); print(z2); selectImage(z); selectImage(z2); I if run like this it works: java -jar ij.jar test1.png test.txt I get this in the log: -2 -3 If I run in batch: java -jar ij.jar test1.png -batch test.txt I get this: -2 -3 Image -2 not found or no images are open. This happens with 1.44e and 1.44f11. Note that if I add the image to the macro directly and not on the command line: open("test.png"); then everything works, in batch mode and not: java -jar ij.jar -batch test2.txt -2 -3 Any ideas? Thanks, Adam |
On Aug 18, 2010, at 5:21 PM, Adam Goode wrote:
> Hi, > > I have this macro: > > > var z = getImageID(); > print(z); > selectImage(z); > > run("Duplicate...", "title=item2"); > var z2 = getImageID(); > print(z2); > > selectImage(z); > selectImage(z2); > > > > I if run like this it works: > java -jar ij.jar test1.png test.txt > > I get this in the log: > -2 > -3 > > > If I run in batch: > java -jar ij.jar test1.png -batch test.txt > > I get this: > -2 > -3 > Image -2 not found or no images are open. > > > This happens with 1.44e and 1.44f11. > > > > Note that if I add the image to the macro directly and not on the > command line: > > open("test.png"); > > then everything works, in batch mode and not: > java -jar ij.jar -batch test2.txt > > -2 > -3 > > > > Any ideas? It works if you add open(getArgument); to the beginning of the macro and run it using java -jar ij.jar -batch test.txt test1.png -wayne |
On 08/18/2010 07:26 PM, Rasband, Wayne (NIH/NIMH) [E] wrote:
> On Aug 18, 2010, at 5:21 PM, Adam Goode wrote: > >> Hi, >> >> I have this macro: >> >> >> var z = getImageID(); >> print(z); >> selectImage(z); >> >> run("Duplicate...", "title=item2"); >> var z2 = getImageID(); >> print(z2); >> >> selectImage(z); >> selectImage(z2); >> >> >> >> I if run like this it works: >> java -jar ij.jar test1.png test.txt >> >> I get this in the log: >> -2 >> -3 >> >> >> If I run in batch: >> java -jar ij.jar test1.png -batch test.txt >> >> I get this: >> -2 >> -3 >> Image -2 not found or no images are open. >> >> >> This happens with 1.44e and 1.44f11. >> >> >> >> Note that if I add the image to the macro directly and not on the >> command line: >> >> open("test.png"); >> >> then everything works, in batch mode and not: >> java -jar ij.jar -batch test2.txt >> >> -2 >> -3 >> >> >> >> Any ideas? > > It works if you add > > open(getArgument); > > to the beginning of the macro and run it using > > java -jar ij.jar -batch test.txt test1.png > > -wayne > Hi, Thanks for the tip. I also found that if I modified ImageJ.java like this: diff -ur source/ij/ImageJ.java source~/ij/ImageJ.java --- source/ij/ImageJ.java 2010-08-24 11:03:00.159768757 -0400 +++ source~/ij/ImageJ.java 2010-08-21 22:41:00.000000000 -0400 @@ -545,10 +545,9 @@ if (arg==null) continue; //IJ.log(i+" "+arg); if (args[i].startsWith("-")) { - if (args[i].startsWith("-batch")) { + if (args[i].startsWith("-batch")) noGUI = true; - Interpreter.batchMode = true; - } else if (args[i].startsWith("-debug")) + else if (args[i].startsWith("-debug")) IJ.debugMode = true; else if (args[i].startsWith("-ijpath") && i+1<nArgs) { Prefs.setHomeDir(args[i+1]); Then it also works. I think the issue is that Interpreter.batchMode has to be true before IJ.open() can run, otherwise the window doesn't get registered with the batch mode images imageTable Vector. I don't know if this breaks other things, but it does fix my batch mode bug shown in the test case above. Thanks, Adam |
Free forum by Nabble | Edit this page |