6

从 db 获取图像后,当我尝试调整它的大小时,通过使用下面的代码传递宽度

        public static BufferedImage resize(final byte[] pImageData,
                    final int width, final int height, final int maxLength, final int minLength, final String imageSubType) throws Exception {

                InputStream is = null;
                BufferedImage resizeImageJpg = null;
                try {

                    is = new ByteArrayInputStream(pImageData);
                    BufferedImage originalImage = ImageIO.read(is);
                     --------------------

    }
   }

在行抛出以下异常:

                    BufferedImage originalImage = ImageIO.read(is);

例外:

Caused by: java.awt.color.CMMException: Invalid image format
    at sun.awt.color.CMM.checkStatus(CMM.java:131)
    at sun.awt.color.ICC_Transform.<init>(ICC_Transform.java:89)
    at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:516)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1169)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1137)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:948)
    at javax.imageio.ImageIO.read(ImageIO.java:1422)
    at javax.imageio.ImageIO.read(ImageIO.java:1326)

关于为什么仅针对某些图像引发此错误的任何想法。图片有什么问题吗。如果是这样,可能的错误是什么

4

1 回答 1

2

顺便说一句,这个 CMMException 问题在 JDK8 中得到了修复(注意http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7064516底部的提交)。我已经确认JDK8 的预发布版本可以正确加载 JDK7 失败的映像,如上所述。

于 2013-10-09T21:21:54.610 回答