我正在使用JAI媒体api和ImageMagick?
ImageMagick有一些可扩展性问题,而基于JNI的JMagick也没有吸引力.与ImageMagick相比,JAI在进行大小调整操作时效果不佳.
有没有人知道任何优秀的工具,无论是开源还是商业本土java并提供高质量的结果?
我尝试了以下代码来完成读写tiff图像的任务:
// Define the source and destination file names.
String inputFile = /images/FarmHouse.tif
String outputFile = /images/FarmHouse.bmp
// Load the input image.
RenderedOp src = JAI.create("fileload", inputFile);
// Encode the file as a BMP image.
FileOutputStream stream =
new FileOutputStream(outputFile);
JAI.create("encode", src, stream, BMP, null);
// Store the image in the BMP format.
JAI.create("filestore", src, outputFile, BMP, null);
Run Code Online (Sandbox Code Playgroud)
但是,当我运行代码时,我收到以下错误消息:
Caused by: java.lang.IllegalArgumentException: Only images with either 1 or 3 bands
can be written out as BMP files.
at com.sun.media.jai.codecimpl.BMPImageEncoder.encode(BMPImageEncoder.java:123)
at …
Run Code Online (Sandbox Code Playgroud) 在Java下,将TIF文件转换为PNG的最佳方法是什么?
简单是可取的,但如果最简单的方法是使用第三方库,那么我会考虑这个解决方案.