JDK-6246622 : ImageIO fails to decode some YCbCr JPEGs
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-03-28
  • Updated: 2011-02-16
  • Resolved: 2005-03-28
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
ImageIO still fails to properly decode some YCbCr JPEG images (e.g. those scanned using Nikon CoolScan). The colors are shifted (red and blue channels are swapped).

See bug #4712797 for a similar problem I reported previously which is now fixed.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached sample program and run:

java JpegView http://www.photica.com/aw/jpeg-colors.jpg

JpegView displays a window, the image on the
left was decoded with ImageIO and is wrong, the image on
the right was decoded with java.awt.Toolkit.createImage()
and looks correct.

Another sample image with the same problem is available here: http://www4.ncsu.edu/~zdpurvis/JPEGColorBugDemo.zip


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both images should look like the image on the right.
ImageIO should not behave differently from the
java.awt.Toolkit JPEG decoder and from other image viewing applications.
ACTUAL -
Shifted colors.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.imageio.*;
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.net.*;

public class JpegView {
	public static void main(String args[]) throws Exception {
		if (args.length < 1) {
			System.err.println("Usage: JpegView <jpeg-url>");
			System.exit(1);
		}
		ImageIcon iiImageIO = new ImageIcon(ImageIO.read(new URL(args
[0])));
		ImageIcon iiToolkit = new ImageIcon(Toolkit.getDefaultToolkit
().createImage(new URL(args[0])));

		JFrame f= new JFrame();
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JLabel lblImageIO = new JLabel(iiImageIO);
		JLabel lblToolkit = new JLabel(iiToolkit);
		f.getContentPane().add(lblImageIO, BorderLayout.WEST);
		f.getContentPane().add(lblToolkit, BorderLayout.EAST);
		f.pack();
		f.setVisible(true);
	}
}


---------- END SOURCE ----------
###@###.### 2005-03-28 10:09:35 GMT

Comments
EVALUATION Attached image is in EXIF format. This case is addressed by fix for 4881314. ###@###.### 2005-03-28 13:23:05 GMT
28-03-2005