Java中的ImageIO图像支持.getImageReadersByMIMEType

时间:2016-04-19 13:49:54

标签: java java-native-interface javax.imageio

我尝试了以下代码。我将libwebp-imageIO.so包含在the WebP-imageio docs中建议的本机库路径中。

ImageInputStream imageInputStream = new FileImageInputStream(imagefile);

Iterator<ImageReader> ite  = ImageIO.getImageReadersByMIMEType("image/webp");
BufferedImage bufferedImage = null;

while (ite.hasNext()) {
    ImageReader imageReader = ite.next();
    imageReader.setInput(imageInputStream);
    bufferedImage = imageReader.read(0);
}

在这段代码中,bufferedimage为null并为webp格式图像抛出以下异常。我相信ImageIO支持webP格式图像,那么为什么它不能读取webp图像文件。

java.lang.NoClassDefFoundError: Could not initialize class com.luciad.imageio.webp.WebP
    at com.luciad.imageio.webp.WebPReader.readHeader(WebPReader.java:58)
    at com.luciad.imageio.webp.WebPReader.read(WebPReader.java:147)
    at javax.imageio.ImageReader.read(ImageReader.java:939)

0 个答案:

没有答案