Login  Register

Help: Batch conversion RAW to TIFF 16-bit

Posted by sdegan on Sep 07, 2010; 9:10pm
URL: http://imagej.273.s1.nabble.com/Help-Batch-conversion-RAW-to-TIFF-16-bit-tp3686996.html

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 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: '<i>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