I am trying to save a TFW file (a text file with map coordinates) as generated by the XYZ2DEM plugin.
This text file must have the same filename as the corresponding TIF, just TFW as extension instead. The problem is that ImageJ always saves text windows as TXT extension, except CSV is also allowed as the poster below requested earlier this year. Can ImageJ be modified to save TEXT files with any extension when this is given? It would make sense to be able to save text files with any extension of choice such as .LOG, .TFW, etc. as long as you know what you are doing. Here is my macro, which currently does not work in the latest version of ImageJ: FileXYZ = "E:\\3D Laser Scan\\Test Scan.xyz"; run("XYZ2DEM Importer", "open=&FileXYZ length=0.001 maximum=0.05 background=0.1 show generate"); selectWindow("Test Scan.tfw"); //select the TFW text window generated by XYZ2DEM saveAs("Text", "E:\\3D Laser Scan\\Test Scan.tfw"); //does not work, the file is saved as E:\\3D Laser Scan\\Test Scan.txt instead Stein Rørvik -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) [E] Sent: 17. april 2015 06:06 To: [hidden email] Subject: Re: Saving Log window as a csv file but not a txt file > On Apr 16, 2015, at 8:38 AM, Tomm <[hidden email]> wrote: > > Hi all, > > I want to save a text of Log window as a csv file. > But the txt file was saved. > How can I change the extension from txt to csv? > Here is my macro code. > -- > dir = getDirectory("Choose a Directory"); name = "test"; > print("10"+","+"20"); saveAs("Text", dir +name + ".csv”); Upgrade to the latest ImageJ daily build (1.49r24) and this macro code will work as expected. -wayne > -- > View this message in context: > http://imagej.1557.x6.nabble.com/Saving-Log-window-as-a-csv-file-but-n > ot-a-txt-file-tp5012505.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 |
Stein Rørvik,
Did you try "File.saveString( string, path )" ? Best Herbie :::::::::::::::::::::::::::::::::::::::::: Am 25.09.15 um 09:49 schrieb Stein Rørvik: > I am trying to save a TFW file (a text file with map coordinates) as > generated by the XYZ2DEM plugin. This text file must have the same > filename as the corresponding TIF, just TFW as extension instead. The > problem is that ImageJ always saves text windows as TXT extension, > except CSV is also allowed as the poster below requested earlier this > year. Can ImageJ be modified to save TEXT files with any extension > when this is given? It would make sense to be able to save text files > with any extension of choice such as .LOG, .TFW, etc. as long as you > know what you are doing. > > Here is my macro, which currently does not work in the latest version > of ImageJ: > > FileXYZ = "E:\\3D Laser Scan\\Test Scan.xyz"; run("XYZ2DEM Importer", > "open=&FileXYZ length=0.001 maximum=0.05 background=0.1 show > generate"); selectWindow("Test Scan.tfw"); //select the TFW text > window generated by XYZ2DEM saveAs("Text", "E:\\3D Laser Scan\\Test > Scan.tfw"); //does not work, the file is saved as E:\\3D Laser > Scan\\Test Scan.txt instead > > Stein Rørvik > > -----Original Message----- From: ImageJ Interest Group > [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) > [E] Sent: 17. april 2015 06:06 To: [hidden email] Subject: Re: > Saving Log window as a csv file but not a txt file > >> On Apr 16, 2015, at 8:38 AM, Tomm <[hidden email]> wrote: >> >> Hi all, >> >> I want to save a text of Log window as a csv file. But the txt file >> was saved. How can I change the extension from txt to csv? Here is >> my macro code. > >> -- dir = getDirectory("Choose a Directory"); name = "test"; >> print("10"+","+"20"); saveAs("Text", dir +name + ".csv”); > > Upgrade to the latest ImageJ daily build (1.49r24) and this macro > code will work as expected. > > -wayne > >> -- View this message in context: >> http://imagej.1557.x6.nabble.com/Saving-Log-window-as-a-csv-file-but-n >> >> >> at Nabble.com. > > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Stein Rørvik
Stein Rørvik,
a more elegant way may be to simply rename the file with suffix ".txt" to one with suffix ".tfw" by using "File.rename( path1, path2 )". HTH Herbie :::::::::::::::::::::::::::::::::::::::::: Am 25.09.15 um 09:49 schrieb Stein Rørvik: > I am trying to save a TFW file (a text file with map coordinates) as > generated by the XYZ2DEM plugin. This text file must have the same > filename as the corresponding TIF, just TFW as extension instead. The > problem is that ImageJ always saves text windows as TXT extension, > except CSV is also allowed as the poster below requested earlier this > year. Can ImageJ be modified to save TEXT files with any extension > when this is given? It would make sense to be able to save text files > with any extension of choice such as .LOG, .TFW, etc. as long as you > know what you are doing. > > Here is my macro, which currently does not work in the latest version > of ImageJ: > > FileXYZ = "E:\\3D Laser Scan\\Test Scan.xyz"; run("XYZ2DEM Importer", > "open=&FileXYZ length=0.001 maximum=0.05 background=0.1 show > generate"); selectWindow("Test Scan.tfw"); //select the TFW text > window generated by XYZ2DEM saveAs("Text", "E:\\3D Laser Scan\\Test > Scan.tfw"); //does not work, the file is saved as E:\\3D Laser > Scan\\Test Scan.txt instead > > Stein Rørvik > > -----Original Message----- From: ImageJ Interest Group > [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) > [E] Sent: 17. april 2015 06:06 To: [hidden email] Subject: Re: > Saving Log window as a csv file but not a txt file > >> On Apr 16, 2015, at 8:38 AM, Tomm <[hidden email]> wrote: >> >> Hi all, >> >> I want to save a text of Log window as a csv file. But the txt file >> was saved. How can I change the extension from txt to csv? Here is >> my macro code. > >> -- dir = getDirectory("Choose a Directory"); name = "test"; >> print("10"+","+"20"); saveAs("Text", dir +name + ".csv”); > > Upgrade to the latest ImageJ daily build (1.49r24) and this macro > code will work as expected. > > -wayne > >> -- View this message in context: >> http://imagej.1557.x6.nabble.com/Saving-Log-window-as-a-csv-file-but-n >> >> >> at Nabble.com. > > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Herbie
No, I did not think of that.
This approach works fine: selectWindow(name + ".tfw"); contents = getInfo("window.contents"); File.saveString(contents, dir + name + ".tfw"); But it is still a workaround. I think letting ImageJ allow text files to be saved with any extension of choice (except those used for image formats) would be more neat. Stein -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Herbie Sent: 25. september 2015 14:03 To: [hidden email] Subject: Re: How to save a TFW file Stein Rørvik, Did you try "File.saveString( string, path )" ? Best Herbie :::::::::::::::::::::::::::::::::::::::::: Am 25.09.15 um 09:49 schrieb Stein Rørvik: > I am trying to save a TFW file (a text file with map coordinates) as > generated by the XYZ2DEM plugin. This text file must have the same > filename as the corresponding TIF, just TFW as extension instead. The > problem is that ImageJ always saves text windows as TXT extension, > except CSV is also allowed as the poster below requested earlier this > year. Can ImageJ be modified to save TEXT files with any extension > when this is given? It would make sense to be able to save text files > with any extension of choice such as .LOG, .TFW, etc. as long as you > know what you are doing. > > Here is my macro, which currently does not work in the latest version > of ImageJ: > > FileXYZ = "E:\\3D Laser Scan\\Test Scan.xyz"; run("XYZ2DEM Importer", > "open=&FileXYZ length=0.001 maximum=0.05 background=0.1 show > generate"); selectWindow("Test Scan.tfw"); //select the TFW text > window generated by XYZ2DEM saveAs("Text", "E:\\3D Laser Scan\\Test > Scan.tfw"); //does not work, the file is saved as E:\\3D Laser > Scan\\Test Scan.txt instead > > Stein Rørvik > > -----Original Message----- From: ImageJ Interest Group > [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) > [E] Sent: 17. april 2015 06:06 To: [hidden email] Subject: Re: > Saving Log window as a csv file but not a txt file > >> On Apr 16, 2015, at 8:38 AM, Tomm <[hidden email]> wrote: >> >> Hi all, >> >> I want to save a text of Log window as a csv file. But the txt file >> was saved. How can I change the extension from txt to csv? Here is my >> macro code. > >> -- dir = getDirectory("Choose a Directory"); name = "test"; >> print("10"+","+"20"); saveAs("Text", dir +name + ".csv”); > > Upgrade to the latest ImageJ daily build (1.49r24) and this macro code > will work as expected. > > -wayne > >> -- View this message in context: >> http://imagej.1557.x6.nabble.com/Saving-Log-window-as-a-csv-file-but- >> n >> >> >> at Nabble.com. > > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |