Login  Register

Help to save open image in Process>Batch>Macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Help to save open image in Process>Batch>Macro

sdegan
Hi All,
I need some help on how to save the open image that results from the batch processing using the Process>Batch>Macro

I have tried the following command at the end of the macro in the 'Batch Process' window. However, this allows me to choose a directory and save only one image at a time. Every time I am prompted to choose the directory and save the image:

//the following is inserted at the end of the macro in the 'Batch Process' window
 
fullpath = getDirectory("");
N = nImages;
for (i=0; i<N; i++) {
    dir = fullpath + getTitle() +".jpg";
    saveAs("jpg", dir);
    run("Close");
}

Is there a way to have the resulted image from the batch to be saved automatically in a specified directory?

Many thanks for any help
 
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Help to save open image in Process>Batch>Macro

Pariksheet Nanda
On Fri, Jun 7, 2013 at 1:47 PM, sdegan <[hidden email]> wrote:
> I need some help on how to save the open image that results from the batch
> processing using the Process>Batch>Macro
>

Since your goal seems to be just changing the image file format, it
would be better to use:

    Process > Multiple Image Processor

You can set your Output image format type to Jpeg.

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

Re: Help to save open image in Process>Batch>Macro

Tiago Ferreira-2
In reply to this post by sdegan
Dear Simone,

On 2013.06.07, at 13:47 , sdegan wrote:
> However, this allows me to choose a directory and save only one image at a time.
> Every time I am prompted to choose the directory and save the image:

Using getDirectory() without arguments is equivalent of using getDirectory("Choose a Directory"),
i.e., it will trigger a prompt for user-selected directory.

> Is there a way to have the resulted image from the batch to be saved automatically in a specified directory?

Sure. Have a look at http://imagej.nih.gov/ij/developer/macro/functions.html#getDirectory

Thus, in your macro you could use:

  // to save the jpg copy next to loaded image
  fullpath = getDirectory("image");

  // to save the jpg on the User's home folder
  fullpath = getDirectory("home");

  // to save the jpg on the subdirectory "output" of the home folder
  fullpath = getDirectory("home") + output + File.separator;  

  // to save the jpg on some fixed location
  fullpath = "Path/To/Some/Fixed/Folder/;


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