srcpath: e:bbb.tif (图片路径)
targetPath: e:aaa.png(转换后的图片路径)
try {
this.tif2Jpg(srcpath, targetPath);
} catch (IOException e1) {
e1.printStackTrace();
System.out.println(“tif转换jpg失败!”);
}
public void tif2Jpg(String srcFile, String descFile) throws IOException{
RenderedOp src = JAI.create(“fileload”, srcFile);
OutputStream os = new FileOutputStream(descFile);
JPEGEncodeParam param = new JPEGEncodeParam();
//指定格式类型,jpg 属于 JPEG 类型
ImageEncoder enc = ImageCodec.createImageEncoder(“JPEG”, os, param);
enc.encode(src);
os.close();
}
jar包:
com.sun
jai_core
1.1.3
com.sun
jai_codec
1.1.3