setCompressionType 错误
有人可以帮助纠正这个代码吗?
我正在使用 JAI
并尝试将 JPG 文件压缩为无损 这是我的代码
`ImageWriter writer= (JPEGImageWriter) ImageIO.getImageWritersByFormatName("jpeg").next();
javax.imageio.plugins.jpeg.JPEGImageWriteParam param = (JPEGImageWriteParam)
writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionType("JPEG-LOSSLESS");`
这部分总是错误 param.setCompressionType("JPEG-LOSSLESS");
错误是java.lang.IllegalArgumentException:未知的压缩类型! 在 javax.imageio.ImageWriteParam.setCompressionType(ImageWriteParam.java:1023)
Is there someone that can help to correct this code?
I'm working with JAI
and I'm trying to compress JPG file to Losse-less
here's my code
`ImageWriter writer= (JPEGImageWriter) ImageIO.getImageWritersByFormatName("jpeg").next();
javax.imageio.plugins.jpeg.JPEGImageWriteParam param = (JPEGImageWriteParam)
writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionType("JPEG-LOSSLESS");`
It's always error in this part param.setCompressionType("JPEG-LOSSLESS");
the error is java.lang.IllegalArgumentException: Unknown compression type!
at javax.imageio.ImageWriteParam.setCompressionType(ImageWriteParam.java:1023)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只能使用支持的压缩类型。检查 支持哪些
param.getCompressionTypes()
。除此之外,尝试以下代码(使用更新的 jpeg 无损标准
JPEG-LS
):You can only use compression types that are supported. Check which are supported by
param.getCompressionTypes()
.Other then that, try this code (using newer jpeg lossless standard
JPEG-LS
):