United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6517427 GIF Reader throws IIOException when reading a Indexed GIF image with an embedded color profile
JDK-6517427 : GIF Reader throws IIOException when reading a Indexed GIF image with an embedded color profile

Details
Type:
Bug
Submit Date:
2007-01-25
Status:
Closed
Updated Date:
2012-10-01
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
generic,windows_xp
Sub-Component:
javax.imageio
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2,6,6u15,6u23
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
I am reading the attached image using ImageIO's GIF Reader and GIF Reader is throwing the following exception -

Exception in thread "main" javax.imageio.IIOException: Unexpected block type 0!
at com.sun.imageio.plugins.gif.GIFImageReader.readMetadata(GIFImageReader.java:722)
at com.sun.imageio.plugins.gif.GIFImageReader.read(GIFImageReader.java:794)
at javax.imageio.ImageReader.readAll(ImageReader.java:1050)
at MetadataViewer.main(MetadataViewer.java:82)

The attached image is a GIF image having an embedded color profile. This is reproducible on JDK6/7 on all platforms. Toolkit API is able to read the image properly. 

Run the attached tests as follows -
java KannanImageIOTest <img>
java MetadataViewer <img>

                                    

Comments
EVALUATION

The gif file in question is uses application extension "ICCRGBG1012"
that is described here: http://www.color.org/wpaper2.html.

However, implementation of this extension seems to be not completely
valid from the spec-gif89a point of view. Namely, this spec states that
size of application block should be 11 (the sum of length of application
ID field and length of auth code field) and application extension data
should be represented as subsequent data sub-blocks.

Contrary to this, this extension uses the rest of application extension
block to store data. The ImageIO GIF reader does not ready to meet application
data inside application block and tries to extract it form wrong position
that leads to described failure of decoding routine.

To solve this problem I suggest to check declared length of application
extension block and treat rest of application extension block content
(i.e. everything else than application ID and auth code) as an application
extension data.

*** (#1 of 1): [ UNSAVED ] ###@###.###
                                     
2007-01-25



Hardware and Software, Engineered to Work Together