在Tiff的getImageWritersByFormatName中出现问题。获得图像编写者 [英] Issue in getImageWritersByFormatName for Tiff. Getting image writer
问题描述
我正在尝试将PDF转换为tif图像。我使用以下代码按格式获取图像编写器。
I am trying to convert PDF to tif images. I use following code to get the image writers by format.
Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("TIFF");
if (writers == null || !writers.hasNext()) {
throw new ImageWritingException();
}
当我在Eclipse中独立运行应用程序时,这很好用。但是当我将应用程序部署到linux中的tomcat服务器时, writers == null 为false,但!writers.hasNext 为true,导致抛出异常。
This works fine when I run the application standalone in Eclipse. But when I deploy the application to tomcat server in linux, writers==null is false but !writers.hasNext is true resulting to throw Exception.
我使用maven来构建战争项目。
I use maven to build the project to war.
我在pom文件中有以下依赖项。
I have following dependencies in the pom file.
<dependency>
<groupId>org.icepdf</groupId>
<artifactId>icepdf-core</artifactId>
</dependency>
<dependency>
<groupId>com.sun.media</groupId>
<artifactId>jai_imageio</artifactId>
</dependency>
<dependency>
<groupId>com.sun.media</groupId>
<artifactId>jai-codec</artifactId>
</dependency>
<dependency>
<groupId>javax.media</groupId>
<artifactId>jai_core</artifactId>
</dependency>
两种环境之间有什么区别?我该如何解决这个问题?
What can be the difference between two environments? How can I fix this issue?
推荐答案
Tiff支持由Java Advanced Imaging插件提供 jai_core.jar
。
Tiff support is provided by the Java Advanced Imaging plugin jai_core.jar
.
为了正常工作,需要将jar文件添加到JVM的 ext
目录中,否则它将无法正确注册
In order to work correctly, the jar file needs to be added to the JVM's ext
directory, otherwise it won't register properly
这篇关于在Tiff的getImageWritersByFormatName中出现问题。获得图像编写者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!