Java - 2nd page of multi-page-tiff goes black if compression is enabled

206 Views Asked by At

i want to create a multi-page-TIFF with one or two pages. The problem is: if I use the ImageWriteParam to set any kind of compression the 2nd page in the TIFF goes completely black. If i don't set a compression it is displayed fine (the file is really big though)

Here is a snipped of what I am doing:

ImageWriter writer = tiffspi.createWriterInstance();
writer.setOutput(ios);

ImageWriteParam param = writer.getDefaultWriteParam();
// TODO fix compression - 2nd page is always black!
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionType("JPEG");
param.setCompressionQuality(1f);

writer.prepareWriteSequence(null);
writer.writeToSequence(new IIOImage(frontImage, null, null), param);
if (backImage != null) {
  writer.writeToSequence(new IIOImage(backImage, null, null), param);
}
writer.endWriteSequence();
writer.dispose();

Any ideas?

0

There are 0 best solutions below