Wrong argument parsing in headless mode

parameters
headless
Tags: #<Tag:0x00007fd541f9afd8> #<Tag:0x00007fd541f9adf8>

#1

Dear All,

I have a strange mistake:
When i run this script in Image J it opens a dialog, asks for a filename and writes the file as expected:

#@String filename
import os
from ij import IJ, ImagePlus

imp = IJ.createImage("Untitled", "8-bit random", 100, 100, 1)
file_path=os.path.join("D:\\Fiji",filename)
IJ.saveAs(imp, "Tiff",file_path)
IJ.run("Quit")

If i call it afterwards in headless and pass on an other filename, it still remembers what it did last and
writes a file with the wrong name??

I use the same synatax i would do at linux:

D:\\Fiji\Fiji.app\ImageJ.exe --ij2 --headless --run D:\\Fiji\Hello_file_.py 'filename="test.tif"'

Do you have any idea what might go wrong on windows 10, Fiji 1.51s Java 1.8.0_66 64 bit.

Thanks a lot & Kind regards

Tobias


#2

I suspect something might go wrong with the persisting of parameters: when you run a script, ImageJ remembers your last parameters and prefills them for you. But when you provide a parameter from the command line, this one should take preference over the persisted value, otherwise it’s a bug.

You might be able to work around the issue by adding (persist = false) to your script parameter:

#@String (persist = false) filename

Are you implying that the same issue does not occur when you run your script on Linux? That would indeed be strange…


#3

Dear Jan,

Thanks a lot!

Yes the same issue does not occur in linux.
This, also makes sense to me.

Provided i pass on successfully the correct new value, it should not matter,
if ImageJ still knows the old value. It should be replaced, or?

After adding (persists=false) on Windows, no file is written at all.
If i remove --headless, i get this message:

“filename is required but unset”

suggesting that the Windows Fiji version has a bug, or my syntax (which works on linux) is wrong:

I call Fiji on command line by:

D:\Fiji\Fiji.app\ImageJ.exe --ij2 --headless --run D:\Fiji\Hello_file2_.py ‘filename=“test.tif”’

Thanks a lot & Kind regards

Tobias