Login  Register

How to save all opened images

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

How to save all opened images

sdegan
15 posts
Hi All,

I am trying to save all the opened images I have on the stage after running a macro. I know that I have to assign IDs to the opened images but then I do not know how to get them saved in a directory. Ideally I would like to add the saveall command at the end of the macro:

// get image IDs of all open images
ids=newArray(nImages);
for (i=0;i<nImages;i++) {
selectImage(i+1);
ids[i]=getImageID;
}

Can someone help?

Thanks
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to save all opened images

Juanjo Vega
82 posts
Dear Simone,

I'm not sure if this is exactly what you need, but if you add a line to
your macro:

// get image IDs of all open images
ids=newArray(nImages);
for (i=0;i<nImages;i++) {
        selectImage(i+1);
        ids[i]=getImageID;

        saveAs("Jpeg", "/home/juanjo/Desktop/img00000"+ids[i]+".jpg");
}

You can save all the currently opened images to a folder.

Hope this help.

Have a nice weekend :)

Juanjo.


On Fri, 2010-09-10 at 08:36 -0700, sdegan wrote:

> Hi All,
>
> I am trying to save all the opened images I have on the stage after running
> a macro. I know that I have to assign IDs to the opened images but then I do
> not know how to get them saved in a directory. Ideally I would like to add
> the saveall command at the end of the macro:
>
> // get image IDs of all open images
> ids=newArray(nImages);
> for (i=0;i<nImages;i++) {
> selectImage(i+1);
> ids[i]=getImageID;
> }
>
> Can someone help?
>
> Thanks
>
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to save all opened images

newtonEMBL
1 post
In reply to this post by sdegan
better still...

// get image IDs of all open images
dir = getDirectory("Choose a Directory");
ids=newArray(nImages);
for (i=0;i<nImages;i++) {
        selectImage(i+1);
        title = getTitle;
        print(title);
        ids[i]=getImageID;

        saveAs("tiff", dir+title);
}