Reputation: 385
ImageIO.read works for most of my images but throwing this exception for a particular jpg image.
im = ImageIO.read(this.getClass().getResourceAsStream("plan3v2.jpg"));
this line throwing exception:
Exception in thread "main" java.awt.color.CMMException: LCMS error 12288
at sun.java2d.cmm.lcms.LCMS.getProfileData(Native Method)
at java.awt.color.ICC_Profile.getData(ICC_Profile.java:1310)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.setImageData(JPEGImageReader.java:652)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(JPEGImageReader.java:593)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader.java:338)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:470)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(JPEGImageReader.java:586)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1004)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:984)
at javax.imageio.ImageIO.read(ImageIO.java:1438)
at javax.imageio.ImageIO.read(ImageIO.java:1342)
at TestClass.run(TestClass.java:13)
at TestClass.main(TestClass.java:8)
Not sure what the error "LCMS error 12288" mean.
Is there any alternative api that can read such images?
Thanks in advance.
Upvotes: 0
Views: 993
Reputation: 27094
The "LCMS error" exception message you see, originates from the LittleCMS color management module, that was introduced first in OpenJDK, but has now replaced KCMS (the original Kodak CMM used by Sun in their Java implementations) in Oracle JDK8.
Assuming the image is the same as referred to from this RedHat bug report (it has the same file name, and causes the same exception), the TwelveMonkeys ImageIO JPEGImageReader plugin can read it*.
The embedded ICC profile in the image is corrupt, so it is simply ignored by my reader, but the image is fully readable and looks okay still.
To use the plugin, you only need to place the plugin with dependencies on class path (see example). Your existing code should then just work as before (without the exception that is). No need to change or recompile anything.
*) I've only tested on JDK 1.6 and OpenJDK 7 on OS X and JDK 7 and 8 on Windows, but it shouldn't matter. :-)
Upvotes: 2
Reputation: 6306
What version of jre are you using? It appears this is fixed in 1.7.60.
http://bugs.java.com/view_bug.do?bug_id=6839133
https://bugs.openjdk.java.net/browse/JDK-6839133
Upvotes: 0