我不能使用 jai-imageio / jai-imageio-jpeg2000。

huangapple go评论70阅读模式
英文:

I can't use jai-imageio / jai-imageio-jpeg2000

问题

以下是翻译好的内容:

我正在尝试使用最初的java.net项目jai-imageio-core的社区分支(上游不再可用),并将其用于编写jpeg2000图像。核心imageIO项目的分支可在此处找到:这里

而jpeg2000 spi在这里:这里

我只是想运行jpeg2000 spi的最简单测试之一:

    IIORegistry registry = IIORegistry.getDefaultInstance();
    registry.registerServiceProvider(new com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi());

    String[] suff = ImageIO.getWriterFileSuffixes();
    Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("jp2");

但它找不到任何能处理这个jp2扩展名的ImageWriter。然而,在J2KImageReaderSpi类中它被正确地定义。

我发现的问题是JVM(我正在使用Java 8)没有使用图像io的分支,而是使用了JDK默认的图像io版本。这可能是我问题的原因。我做错了什么?

英文:

I am trying to use the community fork of the original java.net project jai-imageio-core (which is no longer available upstream), and use it to write jpeg2000 images. The fork for the core imageIO project is available at: here

And the jpeg2000 spi is at: here

I am just trying to run one of the simplest tests for the jpeg2000 spi:

    IIORegistry registry = IIORegistry.getDefaultInstance();
    registry.registerServiceProvider(new com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi());
    
    String[] suff = ImageIO.getWriterFileSuffixes();
    Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("jp2");

But it does not find any ImageWriter which can handle this jp2 extension. However, it is correctly defined in the J2KImageReaderSpiclass.

What I detected is that the JVM (I'm using Java 8) does not use the fork for imageio but the JDK default imageio version. Which might be the reaosn for my problem. What did I do wrong?

答案1

得分: 2

>     registry.registerServiceProvider(new J2KImageReaderSpi());
>     
> 我做错了什么?

你注册了`J2KImageReaderSpi`(*Reader*),但是你在寻找`J2KWriter`(*Writer*)。

如果你想要写入JPEG2000,尝试注册`J2KImageWriterSpi`代替:

    registry.registerServiceProvider(new J2KImageWriterSpi());

尽管我认为如果JAR文件包含了正确的`META-INF/services`条目,并且你将JAR放在类路径中,这应该会自动发生。
英文:

> registry.registerServiceProvider(new J2KImageReaderSpi());
>
> What did I do wrong?

You were registering the J2KImageReaderSpi (Reader), while you are were looking for the J2KWriter (Writer).

If you want to write JPEG2000, try registering the J2KImageWriterSpi instead:

registry.registerServiceProvider(new J2KImageWriterSpi());

Although I think this should just happen automatically if the JARs contain the correct META-INF/services entries, and you place the JAR on the class path.

huangapple
  • 本文由 发表于 2020年9月15日 00:19:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/63888185.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定