更新时间:2023-01-18 15:06:10
经过一些研究和测试,找到了一种将TIFF转换为JPEG的方法,很抱歉等待很长时间只上传了这个答案。
Had gone through some study and testing, found a method to convert TIFF to JPEG and sorry for pending so long only uploaded this answer.
SeekableStream s = new FileSeekableStream(inFile);
TIFFDecodeParam param = null;
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);
RenderedImage op = dec.decodeAsRenderedImage(0);
FileOutputStream fos = new FileOutputStream(otPath);
JPEGEncodeParam jpgparam = new JPEGEncodeParam();
jpgparam.setQuality(67);
ImageEncoder en = ImageCodec.createImageEncoder("jpeg", fos, jpgparam);
en.encode(op);
fos.flush();
fos.close();
p / s:otPath是指您想要存储JPEG图像的路径。
例如:C:/image/abc.JPG;
inFile是输入文件,它是TIFF文件
p/s: otPath is meant to the path that you would like to store your JPEG image. For example: "C:/image/abc.JPG"; inFile is the input file which is the TIFF file
至少这种方法对我来说是可行的。如果还有其他更好的方法,请与我们分享。
At least this method is workable to me. If there is any other better method, kindly share along with us.
谢谢和问候,