This discussion is archived
0 Replies Latest reply: Apr 17, 2013 2:11 AM by 1003569 RSS

Extract Pages from Multipage Tiff

1003569 Newbie
Currently Being Moderated
Hello,
I'm trying to save all pages from a multipage tiff file into separated files. The following code works fine and saves the separated files, but i can't delete these files when the work is done, because it is used by java. I already close every file, so I don't know what to do. Any idea?
Thank you!

FileSeekableStream fss = new FileSeekableStream(“c:\test.tiff”);
ImageDecoder imde = ImageCodec.createImageDecoder("tiff", fss, null);
int count = imde.getNumPages();
TIFFEncodeParam param = new TIFFEncodeParam();
param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
param.setLittleEndian(false);
for (int ii = 0; ii < count; ii++)
{
     RenderedImage page = imde.decodeAsRenderedImage(ii);
     File f = new File(“c:\Test + "." + (ii+1));
     ParameterBlock pb = new ParameterBlock();
     pb.addSource(page);
     pb.add(f.getPath());
     pb.add("tiff");
     pb.add(param);
     RenderedOp r = JAI.create("filestore",pb);
     r.dispose();
     r = null;
     pb = null;
     f = null;
     page = null;
     param = null;
}
fss.close();
fss = null;
imde = null;

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points