saveas TIFF without get filelist

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

saveas TIFF without get filelist

Emanuele Martini
This post was updated on .
Hi to all,
I have a problem with saving as tiff an opened image in a macro/function.

I write a macro that open an image from a path and process it and then want to save to a saving folder:
1) open image_path=path/image1.tif
2) doing something
3) save to save_path=save_dir/PR_image1.tif

I try with this code saveAs("TIFF", save_dir + "PR_" image_name);
where save_dir is a string path like = "path/ema/exp1"
and i retrieve the image name after opening the image using getTitle().

someone has some ideas to figure out from this, I think, simple problem?
Thanks,
Emanuele Martini

P.S.: the name of the image and the save_dir sometimes have spaces...so maybe it could be a problem

P.S.: i used sometimes, in other macros and plugin, the solution with
image_path=getDirectory("Choose image folder");
save_dir=getDirectory("Choose saving folder");
list = getFileList(image_path);
and then iterate in a for
saveAs("TIFF", save_dir+"PR_"+list[i]);
and that works fine...
but in this case I would have a function that operate on a single file like that:
extract(image_path,save_dir)
Image Analyst @Ifom-IEO research campus -MI-
Reply | Threaded
Open this post in threaded view
|

Re: saveas TIFF without get filelist

Lai Ding
Try

 saveAs("TIFF", save_dir + "PR_" +image_name);

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Emanuele Martini
Sent: Wednesday, November 19, 2014 12:13 PM
To: [hidden email]
Subject: saveas TIFF without get filelist

Hi to all,
I have a problem with saving as tiff an opened image in a macro/function.

I write a macro that open an image from a path and process it and then want to save to a saving folder:
1) open image_path=path/image1.tif
2) doing something
3) save to save_path=save_dir/PR_image1.tif

I try with this code saveAs("TIFF", save_dir + "PR_" image_name); where save_dir is a string path like = "path/ema/exp1"
and i retrieve the image name after opening the image using getTitle().

someone has some ideas to figure out from this, I think, simple problem?
Thanks,
Emanuele Martini

P.S.: the name of the image and the save_dir sometimes have spaces...so maybe it could be a problem




-----
Image Analyst @Ifom-IEO research campus -MI-
--
View this message in context: http://imagej.1557.x6.nabble.com/saveas-TIFF-without-get-filelist-tp5010548.html
Sent from the ImageJ mailing list archive at Nabble.com.

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

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

Re: saveas TIFF without get filelist

Emanuele Martini
Yes I try with it...
sorry i lost a plus in my first post.
My try that doesn't work is exactly that :)
saveAs("TIFF", save_dir + "PR_" +image_name);

I really think that is a problem of spaces presents in my path and in my image name...but i don't know how to resolve it.
Thank you,
Emanuele
Image Analyst @Ifom-IEO research campus -MI-
Reply | Threaded
Open this post in threaded view
|

Re: saveas TIFF without get filelist

Rasband, Wayne (NIH/NIMH) [E]
On Nov 19, 2014, at 12:57 PM, Emanuele Martini <[hidden email]> wrote:
>
> Yes I try with it...
> sorry i lost a plus in my first post.
> My try that doesn't work is exactly that :)
> saveAs("TIFF", save_dir + "PR_" +image_name);
>
> I really think that is a problem of spaces presents in my path and in my
> image name...but i don't know how to resolve it.

Spaces should not be a problem but you need to add a path separator if ‘save_dir’ does not end with one. The following example, which has a space in both the path and in the image name, works as expected:

  dir = "/Users/wayne/Images/test dir";
  name = "image name.tif";
  saveAs("tif", dir +"/" +name);

-wayne

> -----
> Image Analyst @Ifom-IEO research campus -MI-
> --
> View this message in context: http://imagej.1557.x6.nabble.com/saveas-TIFF-without-get-filelist-tp5010548p5010551.html
> Sent from the ImageJ mailing list archive at Nabble.com.



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

Re: saveas TIFF without get filelist

Kenton Arkill
In reply to this post by Emanuele Martini
Without seeing the macro I can't tell, but often these things need the file
separator function:
*File.separator*

*Kenton*

On 19 November 2014 17:57, Emanuele Martini <[hidden email]>
wrote:

> Yes I try with it...
> sorry i lost a plus in my first post.
> My try that doesn't work is exactly that :)
> saveAs("TIFF", save_dir + "PR_" +image_name);
>
> I really think that is a problem of spaces presents in my path and in my
> image name...but i don't know how to resolve it.
> Thank you,
> Emanuele
>
>
>
> -----
> Image Analyst @Ifom-IEO research campus -MI-
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/saveas-TIFF-without-get-filelist-tp5010548p5010551.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: saveas TIFF without get filelist

Emanuele Martini
This post was updated on .
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Hi to all,
and thank you all.
I resolved; the problem was that i had not create the directory (with File.makeDirectory(save_dir)) before saving.

Have a nice day,
Emanuele
Image Analyst @Ifom-IEO research campus -MI-