This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes javax.imageio.ImageIO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "javax.imageio.ImageIO" Watch "javax.imageio.ImageIO" New topic
Author

javax.imageio.ImageIO

Royston Nadar
Greenhorn

Joined: Jul 26, 2011
Posts: 6

Hi Ranchers,

There's a code written by an ex-colleague of mine which reads BLOBs from DB and display them as jpg in a Word document. 99% of the images work fine. However, there were two images which threw the following exception :

java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:460)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1102)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1070)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:885)
at javax.imageio.ImageIO.read(ImageIO.java:1422)
at javax.imageio.ImageIO.read(ImageIO.java:1326)


The code is actually calling the read() method of javax.imageio.ImageIO by passing the InputStream object obtained from the Blob. The API specification of this method says:

Returns a BufferedImage as the result of decoding a supplied InputStream with an ImageReader chosen automatically from among those currently registered. The InputStream is wrapped in an ImageInputStream. If no registered ImageReader claims to be able to read the resulting stream, null is returned.

and

Throws : IllegalArgumentException - if input is null.

Based on the API documentation, I just want opinions from you guys whether the issue here is :

1. Original image is corrupted
2. InputStream object is null
3. No ImageReader is able to read the InputStream passed.


Thanks!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.imageio.ImageIO
 
Similar Threads
ImageIO
MediaTracker Practices
ImageIO.read(InputStream ..) returns null
Minicraft - 2D Java Game - Help for Beginner
java.lang.IllegalArgumentException: im == null!