I have the following problem. We have an Webservice with Upload Function for images. When you try to upload certain images, it just fails. These images have the right MIMETYPE, they are not CMYK (at least GIMP say they are in RGB). The thrown Exception is: "Unsupported Image Type"! The problem occurs, when trying to start this command:
BufferedImage img = ImageIO.read(new ByteArrayInputStream(image.getData()));
I dig a little deeper and the real exception gets thrown with the ImageIO.read(ImageInputStream stream)
, when he tries to close the stream again!
public static BufferedImage read(ImageInputStream stream)
throws IOException {
if (stream == null) {
throw new IllegalArgumentException("stream == null!");
}
Iterator iter = getImageReaders(stream);
if (!iter.hasNext()) {
return null;
}
ImageReader reader = (ImageReader)iter.next();
ImageReadParam param = reader.getDefaultReadParam();
reader.setInput(stream, true, true);
BufferedImage bi;
try {
bi = reader.read(0, param);
} finally {
reader.dispose();
stream.close();
}
return bi;
}
An Image throwing the exception is this for example:
I hope someone can help me figure out, why this crashes and how to fix it!