Saving Stacks as TIFF multi-page

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Saving Stacks as TIFF multi-page

amsmota
*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
**_____________________________________________________________*
Reply | Threaded
Open this post in threaded view
|

Re: Saving Stacks as TIFF multi-page

amsmota
After some more tries, I changed my code to use the ImageIO plugin (basically I had to, because our files are in a format "Group 6 Fax" or something, that only that plugin can read, afaik).

Now I can read the multi-page TIFF ok, create a stack with them, and save also as a multi-page, but... all the images in the multi-page TIFF are blank....................

I run out of ideas now, somebody has any poiters?

TIA