Posted by
Michael Schmid on
Sep 08, 2010; 7:54am
URL: http://imagej.273.s1.nabble.com/Help-Batch-conversion-RAW-to-TIFF-16-bit-tp3686996p3686997.html
Hi Simone,
strange why you try to do the conversion on writing, not on reading
the file - 'open' always tries to read the file, but obviously it
can't because it is not a native format of ImageJ.
Also, as far as i can see, the variable 'extension' is not set in
your program, and CCN without quotes would be another variable, not a
String constant. And the name of the function convertToTift contains
a typo...
Here is a rough suggestion for the macro code of the loop (no
'convertToTift' needed):
...
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
if(endsWith(list[i],".CCN"))
run("Raw...", ""open=["+dir1+list[i]+"] image=[16-bit
Unsigned] width=640 height=480 offset=359 number=1 gap=0");
else
open(dir1+list[i]);
saveAs(format, dir2+list[i]);
close();
}
...
Michael
________________________________________________________________
On 7 Sep 2010, at 23:10, sdegan wrote:
> Hi All,
>
> I need help to batch convert RAW files with an extension named
> 'CCN' using
> the command File>Import>RAW to TIFF in 16-bit. The conversion
> parameters I
> recorded in with the record macro command in ImageJ are:
>
> run("Raw...", image=[16-bit Unsigned] width=640 height=480 offset=359
> number=1 gap=0");
>
> The following is a modified plugin I found
>
http://rsb.info.nih.gov/ij/macros/BatchConvert.txt here :
>
> dir1 = getDirectory("Choose Source Directory ");
> format = getFormat();
> dir2 = getDirectory("Choose Destination Directory ");
> list = getFileList(dir1);
> setBatchMode(true);
> for (i=0; i<list.length; i++) {
> showProgress(i+1, list.length);
> open(dir1+list[i]);
> if (format=="CCN TIFF" || format=="GIF")
> convertToTiff();
> saveAs(format, dir2+list[i]);
> close();
> }
>
> function getFormat() {
> formats = newArray("TIFF", "8-bit TIFF", "JPEG", "GIF", "PNG",
> "PGM", "BMP", "FITS", "Text Image", "ZIP", "Raw");
> Dialog.create("Batch Convert");
> Dialog.addChoice("Convert to: ", formats, "TIFF");
> Dialog.show();
> return Dialog.getChoice();
> }
>
> function convertToTift() {
> if (extension==CCN)
> run("Raw...", "image=[16-bit Unsigned] width=640 height=480
> offset=359 number=1 gap=0")
> else
> run("Tiff");
> }// JavaScript Document
>
> I am not sure if I have modified the script correctly and I believe it
> contains errors. I keep having a pop up window telling: 'File is
> not in a
> supported form, a reader plugin is not available, or it was not found.
> xxxxx.CCN'
>
> Any help to make this macro working is appreciated.
>
> Many thanks