I'm writing a java program to convert the tiff files to separate images , However I'm not able to use ImageDecoder as my tiff files doesn't contains II* as the starting , My tiff file starts with some header then the images starts with II* . Please advise how to remove the header part before II* in tiff images . Below is the code that I'm using to seperate the images , However I hit exception as below due to tiff not start with II*
Exception in thread "main" java.lang.IllegalArgumentException: Bad endianness tag (not 0x4949 or 0x4d4d).
below is my method to seperete the images from tiff.
FileSeekableStream ss = new FileSeekableStream("D:\\Users\\Vinoth\\workspace\\Testing\\Testing.tif");
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", ss, null);
int count = dec.getNumPages();
TIFFEncodeParam param = new TIFFEncodeParam();
param.setLittleEndian(false); // Intel
System.out.println("This TIF has " + count + " image(s)");
for (int i = 0; i < count; i++) {
RenderedImage page = dec.decodeAsRenderedImage(i);
File f = new File("D:\\Users\\Vinoth\\workspace\\Testing\\single_" + i + ".tif");
System.out.println("Saving " + f.getCanonicalPath());
ParameterBlock pb = new ParameterBlock();
pb.addSource(page);
pb.add(f.toString());
pb.add("tiff");
pb.add(param);
RenderedOp r = JAI.create("filestore",pb);
r.dispose();