Login  Register

Saving Stacks as TIFF multi-page

Posted by amsmota on Oct 27, 2010; 8:13am
URL: http://imagej.273.s1.nabble.com/Saving-Stacks-as-TIFF-multi-page-tp3686560.html

*Hello.

I'm trying to save a image stack as a TIFF (and put it inside a zip file)
but until now I've been unsuccessful. I tried using both**
ij.plugin.filter.Writer** and **ij.io.FileSaver** **but both are too much
"interactive" for my needs (like popping up messages "file not found" and
the like,which I can't have). So I ended up using some of their code, like
this:


*

           ImageStack images;
           (...)
           ImagePlus[] zimages = { new ImagePlus("images", images) };
            // Create the ZIP file
            String outFilename = name + ".zip";
            ZipOutputStream zos = new ZipOutputStream(new
FileOutputStream(outFilename));
            // Compress the files
            for (int i = 0; i < zimages.length; i++) {
                DataOutputStream out = new DataOutputStream(new
BufferedOutputStream(zos));
                zos.putNextEntry(new ZipEntry(zimages[i].getTitle()));
                FileInfo fi = zimages[i].getFileInfo();
                if (fi.nImages>1){
                    ImagePlus imp = zimages[i];
                    fi.sliceLabels = stack.getSliceLabels();
                }
                TiffEncoder te = new TiffEncoder(fi);
                te.write(out);
                zos.closeEntry();
            }
            // Complete the ZIP file
            zos.close();

*
This basically is the code that was in fact running when I stepped thru the
FileSaver.saveAsTIFF and FileSaver.saveStackAsTIFF.

This kinda of works, but the image is saved inside the ZIP as a single-image
TIFF, only the first image appearing. What am I doing wrong?

Another question is, is the Stack when saved as TIFF, a multi-page TIFF?
Meaning, if other users try to open it with a regular imaging software,
would they be capable to view it as multi-page TIFF?

Thanks in advance.

*
* Melhores cumprimentos / Beir beannacht / Best regards
**_____________________________________________________________*
*António Manuel dos Santos Mota
Contacts: http://card.ly/amsmota
**_____________________________________________________________*