小编典典

Issue in getImageWritersByFormatName for Tiff. Getting image writer

java

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();
        }

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.

I use maven to build the project to war.

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?


阅读 330

收藏
2020-11-30

共1个答案

小编典典

Tiff support is provided by the Java Advanced Imaging plugin jai_core.jar.

In order to work correctly, the jar file needs to be added to the JVM’s ext
directory, otherwise it won’t register properly

2020-11-30