异常" java.awt.color.CMMException:无效的图像格式"调整某些图像时抛出......为什么? [英] Exception "java.awt.color.CMMException: Invalid image format" thrown when resizing certain images...why?

查看:943
本文介绍了异常" java.awt.color.CMMException:无效的图像格式"调整某些图像时抛出......为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从数据库中获取的图像,当我尝试调整其大小,通过使用下面的code传球后宽度

After obtaining an image from db, when i try to resize it, by passing width using the below code

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

    }
   }

以下异常在行抛出:

The following exception is thrown at line:

                    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)

为什么这个错误只对某些图像抛出的任何想法。这有什么错与图像。如果是这样,还有什么能可能出现的错误

Any ideas on why this error is thrown only for certain images. Is there anything wrong with the image. If so, what can be the possible errors

推荐答案

BTW,这CMMException问题在JDK8(注意在的 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7064516 )。我已经证实, JDK8的pre-发布版本正确加载了JDK7失败图片上,如上所述。

BTW, this CMMException problem is fixed in JDK8 (notice the commit at the bottom of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7064516). I've confirmed that a pre-release build of JDK8 properly loads images that JDK7 fails on as described above.

这篇关于异常&QUOT; java.awt.color.CMMException:无效的图像格式&QUOT;调整某些图像时抛出......为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆