Skip to main content

JAI Create tiff exception

No replies
kevin216
Offline
Joined: 2013-02-27
Points: 0

Hi All,

i have got the JAI runtimeException "Caused by: java.lang.RuntimeException: Unsupported combination of photometric interpretation, samples per pixel, and bit depth."

How can i solve the exception?

public static void saveMultipageTiffs(String[] filename, String savePath) throws Exception {
if (filename.length == 0) {
throw new Exception("No available images for this document.");
}
FileOutputStream baos = new FileOutputStream(savePath);
try{
TIFFEncodeParam param = new TIFFEncodeParam();
param.setCompression(TIFFEncodeParam.COMPRESSION_PACKBITS);
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", baos,param);

Vector images = new Vector();
RenderedImage cover = null;
for (int i = 0; i < filename.length; ++i) {
if (i > 0) {
images.add(JAI.create("fileload", filename[i]));
} else {
cover = JAI.create("fileload", filename[i]);
}
}

param.setExtraImages(images.iterator());
encoder.encode(cover);
}
finally{
baos.close();
}
}