problem with getArgument() in macro

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with getArgument() in macro

Michael Elbaum
I'm running a macro from the linux command line and trying to pass it a filename, as in

./Image -macro mymacro.ijm mystack.tif

At the top of the macro I have the lines:

arg = getArgument();
print(arg);
open(arg);

All works as expected if I invoke ImageJ from the directory containing mystack.tif.

However it if sits in another directory, arg is printed but the file is not found, so

./Image -macro mymacro.ijm dir/mystack.tif does not work.


Is there a reason for this, and might it be fixed?


thanks,
Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: problem with getArgument() in macro

Wayne Rasband-2
> On Mar 18, 2020, at 11:51 PM, Michael Elbaum <[hidden email]> wrote:
>
> I'm running a macro from the linux command line and trying to pass it a filename, as in
>
> ./Image -macro mymacro.ijm mystack.tif
>
> At the top of the macro I have the lines:
>
> arg = getArgument();
> print(arg);
> open(arg);
>
> All works as expected if I invoke ImageJ from the directory containing mystack.tif.
>
> However it if sits in another directory, arg is printed but the file is not found, so
>
> ./Image -macro mymacro.ijm dir/mystack.tif does not work.

This

  ./ImageJ -macro macro.ijm /Users/wayne/images/blobs.tif

works for me, where the macro (“macro.ijm”)

   arg = getArgument();
   print("arg="+arg);
   open(arg);

located in the ImageJ/macros folder, opens the blobs.tiff image and outputs

   arg=/Users/wayne/images/blobs.tif

-wayne

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html