United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4924909 : Reading a certain JPEG image fails with IIOException

Details
Type:
Bug
Submit Date:
2003-09-18
Status:
Closed
Updated Date:
2013-08-22
Project Name:
JDK
Resolved Date:
2012-04-19
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.imageio
CPU:
x86
Priority:
P3
Resolution:
Won't Fix
Affected Versions:
1.4.2,5.0
Fixed Versions:
6-pool

Related Reports
Duplicate:
Relates:

Sub Tasks

Description

Name: gm110360			Date: 09/18/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Trying to read a certain JPEG image which is stored with CMYK color profile throws an IIOException when trying to get the image metadata of the (first and only) image in the file.

Apparently the 'old' com.sun.image.codec.jpeg.JPEGImageDecoder is able to read that sample image. But to me this is no solution because it is not portable enough.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Get the sample image from
         http://home.tiscalinet.ch/fmesch/images/example_image.jpg

2. Compile the sample program

3. Run with
         java Test example_image.jpg


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text "That's it. Thanks for your attention" is printed to the console.
ACTUAL -
An IIOException is thrown and dumped.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
javax.imageio.IIOException: ICC APP2 encountered without prior JFIF!
        at com.sun.imageio.plugins.jpeg.JPEGMetadata.<init>(Unknown Source)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageMetadata(Unknown Source)
        at Test.main(Test.java:22)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.*;
import javax.imageio.*;
import javax.imageio.stream.*;
import javax.imageio.metadata.*;

public class Test {

  public static void main(String[] args) {
    if (args.length == 0) {
      System.out.println("Usage: java Test <filename>");
      System.exit(0);
    }

    try {
      File f = new File(args[0]);
      ImageInputStream ios = ImageIO.createImageInputStream(f);
      Iterator readers = ImageIO.getImageReaders(ios);
      if (readers.hasNext()) {
        ImageReader reader = (ImageReader) readers.next();
        reader.setInput(ios, true);
        IIOMetadata metaData = reader.getImageMetadata(0);
      }
      System.out.println("That's it. Thanks for your attention");
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
(1) Load the image into a image processing application and save back. After that the image is readable. This workaround has been tested with the MS Paint program which comes with WIndows XP. See http://home.tiscalinet.ch/fmesch/images/example_image.jpg for the same sample image read and written with MS Paint.

(2) Use com.sun.image.codec.jpeg.JPEGImageDecoder to read the image.
(Incident Review ID: 200735) 
======================================================================

                                    

Comments
PUBLIC COMMENTS

Closed - Will not fix - Reopen if further justification can be provided.
                                     
2012-04-19



Hardware and Software, Engineered to Work Together