java Apache Commons映像将tiff转换为jpg
我需要使用Apache Commons Imaging将tiff
图像转换为jpg
图像。
我试过了,但我不知道如何使用这个库
final BufferedImage image = Imaging.getBufferedImage(new File(image));
final ImageFormat format = ImageFormats.JPEG;
final Map<String, Object> params = new HashMap<>();
return Imaging.writeImageToBytes(image, format, params);
其中image
是要转换的tiff
文件,但我得到
org.apache.commons.imaging.ImageWriteException: This image format (Jpeg-Custom) cannot be written.
我不明白我做错了什么有人能帮忙吗
# 1 楼答案
尝试使用java AWT:
和代码: