The macro builtin function "File.directory()" does not work when
starting ImageJ via command line -batch: 1) create a simple macro $ echo ''open (getArgument()); print (File.directory ());' > ./macro_test.ijm 2) see how File.directory() fails, displaying an empty message on the log window $ ImageJ-linux32 -batch ./macro_test.ijm ./path_to_image As a temporary workaround, I am using "getDirectory('image')" but they are different things. One returns the directory for the last opened using open(), while the other returns the currently active image. I am using ImageJ via FIJI in Debian Squeeze (current stable version) IJ.getVersion: 1.48s IJ.getFullVersion: 1.48s99 Carnë -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Carnë,
On Fri, 14 Mar 2014, Carnë Draug wrote: > The macro builtin function "File.directory()" does not work when > starting ImageJ via command line -batch: > > 1) create a simple macro > > $ echo ''open (getArgument()); print (File.directory ());' > > ./macro_test.ijm I assume you meant a single single quote before the 'open'? > 2) see how File.directory() fails, displaying an empty message on the > log window > > $ ImageJ-linux32 -batch ./macro_test.ijm ./path_to_image Are you sure that this works in _non_ batch mode? It does not work here, and my investigation showed that only File.name is expected to work correctly: https://github.com/imagej/imagej1/blob/644e33c43593d8d1af400f87cb05f7b368aff93e/ij/macro/Functions.java#L2434 Note how OpenDialog.setLastName() is called but not OpenDialog.setLastDirectory(). Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On 14 March 2014 15:45, Johannes Schindelin <[hidden email]> wrote:
> Hi Carnë, > > On Fri, 14 Mar 2014, Carnë Draug wrote: > >> The macro builtin function "File.directory()" does not work when >> starting ImageJ via command line -batch: >> >> 1) create a simple macro >> >> $ echo ''open (getArgument()); print (File.directory ());' > >> ./macro_test.ijm > > I assume you meant a single single quote before the 'open'? Yes, apologies for the mistake. >> 2) see how File.directory() fails, displaying an empty message on the >> log window >> >> $ ImageJ-linux32 -batch ./macro_test.ijm ./path_to_image > > Are you sure that this works in _non_ batch mode? It does not work here, > and my investigation showed that only File.name is expected to work > correctly: > > https://github.com/imagej/imagej1/blob/644e33c43593d8d1af400f87cb05f7b368aff93e/ij/macro/Functions.java#L2434 > > Note how OpenDialog.setLastName() is called but not > OpenDialog.setLastDirectory(). Inspecting it further, it actually returns a completely wrong answer. I start FIJI normally. I go to "File > Open..." and select a figure that is *not* on the FIJI directory. Then, "Plugins > Macros > Run ..." and select a macro with the single line "print (File.directory ());". The log window appears with the path for the FIJI directory. I originally had the image on the same directory as FIJI so I didn't notice that it was giving the wrong value there either. Carnë -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Carnë Draug
On Mar 14, 2014, at 10:45 AM, Carnë Draug wrote:
> The macro builtin function "File.directory()" does not work when > starting ImageJ via command line -batch: The latest ImageJ daily build (1.48t12) fixes a bug the caused the File.directory macro function to not work as expected after calling the open(path) macro function. Using the daily build, this test macro path = "/Users/wayne/Pictures/Sandhills.jpg"; open(path); print("path: "+path); print ("dir: "+File.directory ()); print ("name: "+File.name ()); outputs path: /Users/wayne/Pictures/Sandhills.jpg dir: /Users/wayne/Pictures/ name: Sandhills.jpg With earlier versions of ImageJ, it outputs path: /Users/wayne/Pictures/Sandhills.jpg dir: name: Sandhills.jpg -wayne > 1) create a simple macro > > $ echo ''open (getArgument()); print (File.directory ());' > ./macro_test.ijm > > 2) see how File.directory() fails, displaying an empty message on the log window > > $ ImageJ-linux32 -batch ./macro_test.ijm ./path_to_image > > As a temporary workaround, I am using "getDirectory('image')" but they > are different things. One returns the directory for the last opened > using open(), while the other returns the currently active image. > > I am using ImageJ via FIJI in Debian Squeeze (current stable version) > IJ.getVersion: 1.48s > IJ.getFullVersion: 1.48s99 > > Carnë -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Carnë Draug
On 14 March 2014 18:01, Rasband, Wayne (NIH/NIMH) [E]
<[hidden email]> wrote: > This bug should be fixed in the latest ImageJ daily build. With the daily build (1.48t12), this test macro ("test_macro.ijm") > > arg = getArgument(); > print("arg: "+arg); > open(arg); > print ("dir: "+File.directory ()); > print ("name: "+File.name ()); > > works as expected when called on OS X using > > java -jar ij.jar -batch test_macro.ijm path_to_image Hi Wayne I have updated to 1.48t12 and using your example I can confirm that the fix also works in Linux 32 bit. > If it does not work as expected when called using the Fiji launcher then submit a bug report using Fiji's Help>Submit a Bug command. I have also checked this and can confirm that the bug is fixed with the 32 bit Linux FIJI launcher. Kudos to dscho (I'm guessing that is Johannes Schindelin) who helped on fixing this. I certainly don't deserve much recognition, I only reported the bug and never even tried to read Java [1]. Thank you, Carnë [1] https://github.com/imagej/imagej1/commit/68bfafe09233c84618876b8f7b8308913b0c9cba#commitcomment-5682840 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |