Batch Converter

Author: Wayne Rasband (wsr at
History: 2000/12/14: First version
2000/12/14: Works more reliably from the command line
2003/01/27: Adds option to convert to 8-bit TIFF
2004/12/29: Added BatchConvert macro
2008/04/15: Updated to use IJ.getDiretory(), IJ.openImage() and IJ.saveAs()
2009/02/10: Added "Make Grayscale" option; works with 48-bit RGB TIFFs
Installation: This plugin is built into ImageJ 1.43 and later as the Process>Batch>Convert command.
Description: Converts a folder of images in any format supported by ImageJ's File>Open command (TIFF, JPEG, DICOM, GIF, PNG, PGM, BMP, FITS, ZIP Compressed TIFF) to TIFF, 8-bit TIFF, JPEG, GIF, PNG, PGM, BMP, FITS, Text Image, ZIP or Raw format. The plugin displays three dialogs. In the first, select the source folder. In the second, select the format you want to convert to. In the third, select the destination folder.

Here is what BatchConvert, the macro version of this plugin, looks like:

  dir1 = getDirectory("Choose Source Directory ");
  format = getFormat();
  dir2 = getDirectory("Choose Destination Directory ");
  list = getFileList(dir1);
  for (i=0; i<list.length; i++) {
     showProgress(i+1, list.length);
     if (format=="8-bit TIFF" || format=="GIF")
     saveAs(format, dir2+list[i]);
  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");;
       return Dialog.getChoice();

  function convertTo8Bit() {
      if (bitDepth==24)
          run("8-bit Color", "number=256");

|Plugins | Home |