Login  Register

Re: problem with getArgument() in macro

Posted by Wayne Rasband-2 on Mar 19, 2020; 7:36pm
URL: http://imagej.273.s1.nabble.com/problem-with-getArgument-in-macro-tp5023067p5023072.html

> 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