Changes between Version 3 and Version 4 of Export


Ignore:
Timestamp:
06/05/10 12:09:59 (9 years ago)
Author:
melissa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Export

    v3 v4  
    9595== Converting to multiple files == 
    9696 
     97The recommended method of converting to multiple files is to use a single IFormatWriter, like so: 
     98 
     99{{{ 
     100  // you should have set up a reader as in the first example 
     101  ImageWriter writer = new ImageWriter(); 
     102  writer.setMetadataRetrieve(MetadataTools.asRetrieve(reader.getMetadataStore())); 
     103  // replace this with your own filename definitions 
     104  // in this example, we're going to write half of the planes to one file 
     105  // and half of the planes to another file 
     106  String[] outputFiles = new String[] {"/path/to/file/1.tiff", "/path/to/file/2.tiff"}; 
     107  writer.setId(outputFiles[0]); 
     108 
     109  int planesPerFile = reader.getImageCount() / outputFiles.length; 
     110  for (int file=0; file<outputFiles.length; file++) { 
     111    writer.changeOutputFile(outputFiles[file]); 
     112    for (int image=0; image<planesPerFile; image++) { 
     113      int index = file * planesPerFile + image; 
     114      writer.saveBytes(image, reader.openBytes(index)); 
     115    } 
     116  } 
     117 
     118  reader.close(); 
     119  writer.close(); 
     120}}} 
     121 
     122The advantage here is that the relationship between the files is preserved when converting to formats that support multi-file datasets internally (namely OME-TIFF).  If you are only converting to graphics formats (e.g. JPEG, AVI, MOV), then you could also use a separate IFormatWriter for each file, like this: 
     123 
     124{{{ 
     125  // again, you should have set up a reader already 
     126  String[] outputFiles = new String[] {"/path/to/file/1.avi", "/path/to/file/2.avi"}; 
     127  int planesPerFile = reader.getImageCount() / outputFiles.length; 
     128  for (int file=0; file<outputFiles.length; file++) { 
     129    ImageWriter writer = new ImageWriter(); 
     130    writer.setMetadataRetrieve(MetadataTools.asRetrieve(reader.getMetadataStore())); 
     131    writer.setId(outputFiles[file]); 
     132    for (int image=0; image<planesPerFile; image++) { 
     133      int index = file * planesPerFile + image; 
     134      writer.saveBytes(image, reader.openBytes(index)); 
     135    } 
     136    writer.close(); 
     137  } 
     138}}} 
    97139 
    98140 
    99 == Known issues (r6306) == 
     141== Known issues (r6494) == 
    100142 
    101  * exporting multiple OME-TIFF files does not work correctly 
    102143 * several writers do not support writing image tiles: 
    103144    - APNG