Skip to main content

[JAI-IMAGEIO] Reading image with strange colors

4 replies [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Schalück, Elmar

Hi,
our customer has an image I need to read and rewrite as a JPEG.
It turns out to read with an incorrect color setting (i.e. red).
I'm reading like this:

File imageFile = new File(filename);
FileSeekableStream fss = new FileSeekableStream(imageFile);
ImageInputStream iis = ImageIO.createImageInputStream(imageFile);
Iterator readers = ImageIO.getImageReaders(iis);
ImageReader reader = (ImageReader) readers.next();
reader.setInput(iis, false);
BufferedImage bi = reader.read(1);

FileOutputStream fos = new FileOutputStream(outfilename);
ImageIO.write(bi,"jpg",fos);
fos.close();

BTW, I'm using the current daily build of JAI-ImageIO.
Thanks
Elmar
[KDVZSeite_1_SW.TIF]
---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Attachment not added (content type not allowed): "KDVZSeite_1_SW.TIF"

Brian Burkhalter

Hi Elmar,

If you have the native component of JAI Image I/O Tools installed this image
is read as you would expect (white background). If on the other hand this is
not installed and the JPEG data embedded in the TIFF file are read using the
Java SE JPEG reader then the background of the image is pink. We are
attempting to determine whether this is a bug in the Java SE JPEG reader. I
will post some more information once this is known, i.e., the Java bug ID. In
any case this does not appear to be a JAI Image I/O Tools problem so I will
likely cloase jai-imageio-core issue 155 as invalid.

Thanks,

Brian

On Thu, 20 Sep 2007, Schalück, Elmar wrote:

> Hi,
> our customer has an image I need to read and rewrite as a JPEG.
> It turns out to read with an incorrect color setting (i.e. red).
> I'm reading like this:
>
> File imageFile = new File(filename);
> FileSeekableStream fss = new FileSeekableStream(imageFile);
> ImageInputStream iis = ImageIO.createImageInputStream(imageFile);
> Iterator readers = ImageIO.getImageReaders(iis);
> ImageReader reader = (ImageReader) readers.next();
> reader.setInput(iis, false);
> BufferedImage bi = reader.read(1);
>
> FileOutputStream fos = new FileOutputStream(outfilename);
> ImageIO.write(bi,"jpg",fos);
> fos.close();
>
> BTW, I'm using the current daily build of JAI-ImageIO.
> Thanks
> Elmar

>^..^< >^..^<

Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Andrey Kuznetsov

Hi Brian,

I think that Java SE JPEG reader is ok.
This TIFF file has incorrect PhotometricInterpretation value (RGB).
So native component of JAI Image I/O tools probably just ignores this
field and therefore gets proper result.

Cheers

Andrey

Brian Burkhalter schrieb:
> Hi Elmar,
>
> If you have the native component of JAI Image I/O Tools installed this
> image is read as you would expect (white background). If on the other
> hand this is not installed and the JPEG data embedded in the TIFF file
> are read using the Java SE JPEG reader then the background of the
> image is pink. We are attempting to determine whether this is a bug in
> the Java SE JPEG reader. I will post some more information once this
> is known, i.e., the Java bug ID. In any case this does not appear to
> be a JAI Image I/O Tools problem so I will likely cloase
> jai-imageio-core issue 155 as invalid.
>
> Thanks,
>
> Brian
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Brian Burkhalter

Andrey,

That is not the basis of my statement. I extracted the JPEG stream contained
within the TIFF file to an entirely separate file. When I viewed this file by
several mechanisms including JAI Image I/O Tools, Java SE, and others, all
results were the same except that of Java SE. From what I can tell this is a
bug in the Java SE JPEG reader which in this case appears to be generating a
result in contravention of its specification here:

http://java.sun.com/javase/6/docs/api/javax/imageio/metadata/doc-files/j...

Brian

On Sun, 23 Sep 2007, Andrey Kuznetsov wrote:

> Hi Brian,
>
> I think that Java SE JPEG reader is ok.
> This TIFF file has incorrect PhotometricInterpretation value (RGB).
> So native component of JAI Image I/O tools probably just ignores this field
> and therefore gets proper result.
>
> Cheers
>
> Andrey
>
>
> Brian Burkhalter schrieb:
>> Hi Elmar,
>>
>> If you have the native component of JAI Image I/O Tools installed this
>> image is read as you would expect (white background). If on the other hand
>> this is not installed and the JPEG data embedded in the TIFF file are read
>> using the Java SE JPEG reader then the background of the image is pink. We
>> are attempting to determine whether this is a bug in the Java SE JPEG
>> reader. I will post some more information once this is known, i.e., the
>> Java bug ID. In any case this does not appear to be a JAI Image I/O Tools
>> problem so I will likely cloase jai-imageio-core issue 155 as invalid.
>>
>> Thanks,
>>
>> Brian
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

>^..^< >^..^<

Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net