如何在java中压缩tiff文件,当我将jpeg文件添加到tiff时,文件大小正在增加
File f2 = new File("D:/KYCDATA/mani/myimage_compressed.jpeg");
BufferedImage image3 = ImageIO.read(f2);
List<BufferedImage> list = new ArrayList<BufferedImage>();
list.add(image3);
File tiffFile = new File("D:/KYCDATA/mani/mani.tiff");
if(tiffFile.exists()) {
tiffFile.delete();
}
ImageOutputStream ios = null;
ImageWriter writer = null;
Iterator it = ImageIO.getImageWritersByFormatName("tiff");
if (it.hasNext()) {
writer = (ImageWriter) it.next();
}
ios = ImageIO.createImageOutputStream(tiffFile);
writer.setOutput(ios);
IIOImage iioImage = null;
for (int i = 0; i < list.size(); i++) {
iioImage = new IIOImage(list.get(i), null, null);
if (i == 0) {
writer.write(iioImage);
} else {
writer.writeInsert(i, iioImage, null);
}
writer.endWriteSequence();