2

I want to load the following gif file using

ImageIO.read(new URL("http://logos.affili.net/120x40/10421.gif"))

and this line throws

javax.imageio.IIOException: Unsupported Image Type

Why? Is there a way to load such files? I only need to load them for determining image size (height and weight) in pixels.

4

1 回答 1

3

The problem is:

a) The image in question "http://logos.affili.net/120x40/10421.gif" is not a GIF despite it's extension, it's a JPEG (this is actually OK for ImageIO, as it doen't look at the file extension anyway, but it's part of the analysis).

b) Further, the image is a CMYK (YCCK) JPEG. The standard JPEGImageReader does not handle CMYK JPEGs, and causes the exception you experience.

You can use my JPEG ImageIO plugin to read such files, or look at the other alternatives like Sanselan/Commons Imaging, JAI etc.

See Java ImageIO IIOException: Unsupported image type? and Pure Java alternative to JAI ImageIO for detecting CMYK images for more information.

于 2013-06-27T08:23:16.997 回答