Skip to main content

EOFException and incorrect StripByteCounts on multipage TIFF

7 replies [Last post]
bdelaco
Offline
Joined: 2007-07-17

Hi All,
I receive an EOFException when trying to read the second page of a 2 pages TIFF.
The file has the following tags:
Page 1: StripOffsets=8, StripByteCounts=36183
Page 2: StripOffsets=36431, StripByteCounts=72751
The total file size is about 72K

I think the reason is the bogus StripByteCounts for the second page.
If I change StripByteCounts to 36320 (ie 72751 - 36431), the image is correctly displayed.

Here is the stack trace:
Exception in thread "main" java.io.EOFException
at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:339)
at com.sun.media.imageioimpl.plugins.tiff.TIFFCodecLibFaxDecompressor.decodeRaw(TIFFCodecLibFaxDecompressor.java:100)
at com.sun.media.imageio.plugins.tiff.TIFFDecompressor.decode(TIFFDecompressor.java:2514)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.decodeTile(TIFFImageReader.java:1137)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1417)
at CorrectFaxMan.main(CorrectFaxMan.java:49)

Does anyone know how I could process such images using Java imageio ?
Or alternatively I would like to preprocess the file to correct the wrong tag before reading it through imageio.

Any idea is welcome.
I tried tiffcp, but it changes the StripByteCounts to about 4000, and the second page gets truncated.

Benoit

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

I wonder whether an enhancement might be made to handle this case?

Is the file compressed and if so using which algorithm?

On Thu, 30 Aug 2007, jai-imageio@javadesktop.org wrote:

> Hi All,
> I receive an EOFException when trying to read the second page of a 2 pages TIFF.
> The file has the following tags:
> Page 1: StripOffsets=8, StripByteCounts=36183
> Page 2: StripOffsets=36431, StripByteCounts=72751
> The total file size is about 72K
>
> I think the reason is the bogus StripByteCounts for the second page.
> If I change StripByteCounts to 36320 (ie 72751 - 36431), the image is correctly displayed.
>
> Here is the stack trace:
> Exception in thread "main" java.io.EOFException
> at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:339)
> at com.sun.media.imageioimpl.plugins.tiff.TIFFCodecLibFaxDecompressor.decodeRaw(TIFFCodecLibFaxDecompressor.java:100)
> at com.sun.media.imageio.plugins.tiff.TIFFDecompressor.decode(TIFFDecompressor.java:2514)
> at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.decodeTile(TIFFImageReader.java:1137)
> at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1417)
> at CorrectFaxMan.main(CorrectFaxMan.java:49)
>
> Does anyone know how I could process such images using Java imageio ?
> Or alternatively I would like to preprocess the file to correct the wrong tag before reading it through imageio.
>
> Any idea is welcome.
> I tried tiffcp, but it changes the StripByteCounts to about 4000, and the second page gets truncated.
>
> Benoit

----------------
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

bdelaco
Offline
Joined: 2007-07-17

Yes, the file is compressed using CCITT T.4.
Here are the complete metadata for the first page (but same compression for page 2)
NewSubfileType (254) : Default
ImageWidth (256) : 1728
ImageLength (257) : 1156
BitsPerSample (258) : 1
Compression (259) : CCITT T.4
PhotometricInterpretation (262) : WhiteIsZero
FillOrder (266) : RightToLeft
StripOffsets (273) : 8
SamplesPerPixel (277) : 1
RowsPerStrip (278) : 1156
StripByteCounts (279) : 36183
XResolution (282) : 200/1
YResolution (283) : 96/1
T4Options (292) : EOLByteAligned
ResolutionUnit (296) : Inch
Software (305) : ImageMan by Data Techniques, Inc.

Benoit

Brian Burkhalter

And the entire image is in one strip.

Would you please file an issue here

https://jai-imageio-core.dev.java.net/issues/enter_bug.cgi?issue_type=DE...

and include the image as an attachment (unless it is confidential).

Thanks ...

On Thu, 30 Aug 2007, jai-imageio@javadesktop.org wrote:

> Yes, the file is compressed using CCITT T.4.
> Here are the complete metadata for the first page (but same compression for page 2)
> NewSubfileType (254) : Default
> ImageWidth (256) : 1728
> ImageLength (257) : 1156
> BitsPerSample (258) : 1
> Compression (259) : CCITT T.4
> PhotometricInterpretation (262) : WhiteIsZero
> FillOrder (266) : RightToLeft
> StripOffsets (273) : 8
> SamplesPerPixel (277) : 1
> RowsPerStrip (278) : 1156
> StripByteCounts (279) : 36183
> XResolution (282) : 200/1
> YResolution (283) : 96/1
> T4Options (292) : EOLByteAligned
> ResolutionUnit (296) : Inch
> Software (305) : ImageMan by Data Techniques, Inc.

----------------
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

bdelaco
Offline
Joined: 2007-07-17

Thanks Brian.
I created a new issue and attached a similar file, generating the same exception.

Benoit

> And the entire image is in one strip.
>
> Would you please file an issue here
>
> https://jai-imageio-core.dev.java.net/issues/enter_bug
> .cgi?issue_type=DEFECT
>
> and include the image as an attachment (unless it is
> confidential).
>
> Thanks ...
>
> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org
> wrote:
>
> > Yes, the file is compressed using CCITT T.4.
> > Here are the complete metadata for the first page
> (but same compression for page 2)
> > NewSubfileType (254) : Default
> > ImageWidth (256) : 1728
> > ImageLength (257) : 1156
> > BitsPerSample (258) : 1
> > Compression (259) : CCITT T.4
> > PhotometricInterpretation (262) : WhiteIsZero
> > FillOrder (266) : RightToLeft
> > StripOffsets (273) : 8
> > SamplesPerPixel (277) : 1
> > RowsPerStrip (278) : 1156
> > StripByteCounts (279) : 36183
> > XResolution (282) : 200/1
> > YResolution (283) : 96/1
> > T4Options (292) : EOLByteAligned
> > ResolutionUnit (296) : Inch
> > Software (305) : ImageMan by Data Techniques, Inc.
>
> ----------------
> 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

Brian Burkhalter

Got it.

Thanks ...

On Thu, 30 Aug 2007, jai-imageio@javadesktop.org wrote:

> Thanks Brian.
> I created a new issue and attached a similar file, generating the same exception.
>
> Benoit
>
>> And the entire image is in one strip.
>>
>> Would you please file an issue here
>>
>> https://jai-imageio-core.dev.java.net/issues/enter_bug
>> .cgi?issue_type=DEFECT
>>
>> and include the image as an attachment (unless it is
>> confidential).
>>
>> Thanks ...
>>
>> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org
>> wrote:
>>
>>> Yes, the file is compressed using CCITT T.4.
>>> Here are the complete metadata for the first page
>> (but same compression for page 2)
>>> NewSubfileType (254) : Default
>>> ImageWidth (256) : 1728
>>> ImageLength (257) : 1156
>>> BitsPerSample (258) : 1
>>> Compression (259) : CCITT T.4
>>> PhotometricInterpretation (262) : WhiteIsZero
>>> FillOrder (266) : RightToLeft
>>> StripOffsets (273) : 8
>>> SamplesPerPixel (277) : 1
>>> RowsPerStrip (278) : 1156
>>> StripByteCounts (279) : 36183
>>> XResolution (282) : 200/1
>>> YResolution (283) : 96/1
>>> T4Options (292) : EOLByteAligned
>>> ResolutionUnit (296) : Inch
>>> Software (305) : ImageMan by Data Techniques, Inc.
>>
>> ----------------
>> 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
> [Message sent by forum member 'bdelaco' (bdelaco)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233413
>
> ---------------------------------------------------------------------
> 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

bdelaco
Offline
Joined: 2007-07-17

Thanks Brian,
This fix has solved all my problems (at least with imageio)

Benoit

On Thu, 30 Aug 2007, jai-imageio@javadesktop.org wrote:

> Got it.
>
> Thanks ...
>
> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org
> wrote:
>
> > Thanks Brian.
> > I created a new issue and attached a similar file,
> generating the same exception.
> >
> > Benoit
> >
> >> And the entire image is in one strip.
> >>
> >> Would you please file an issue here
> >>
> >>
> https://jai-imageio-core.dev.java.net/issues/enter_bug
> >> .cgi?issue_type=DEFECT
> >>
> >> and include the image as an attachment (unless it
> is
> >> confidential).
> >>
> >> Thanks ...
> >>
> >> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org
> >> wrote:
> >>
> >>> Yes, the file is compressed using CCITT T.4.
> >>> Here are the complete metadata for the first page
> >> (but same compression for page 2)
> >>> NewSubfileType (254) : Default
> >>> ImageWidth (256) : 1728
> >>> ImageLength (257) : 1156
> >>> BitsPerSample (258) : 1
> >>> Compression (259) : CCITT T.4
> >>> PhotometricInterpretation (262) : WhiteIsZero
> >>> FillOrder (266) : RightToLeft
> >>> StripOffsets (273) : 8
> >>> SamplesPerPixel (277) : 1
> >>> RowsPerStrip (278) : 1156
> >>> StripByteCounts (279) : 36183
> >>> XResolution (282) : 200/1
> >>> YResolution (283) : 96/1
> >>> T4Options (292) : EOLByteAligned
> >>> ResolutionUnit (296) : Inch
> >>> Software (305) : ImageMan by Data Techniques,
> Inc.
> >>
> >> ----------------
> >> 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
> > [Message sent by forum member 'bdelaco' (bdelaco)]
> >
> >
> http://forums.java.net/jive/thread.jspa?messageID=2334
> 13
> >
> >
> ------------------------------------------------------
> ---------------
> > 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

Brian Burkhalter

Great!

On Sun, 2 Sep 2007, jai-imageio@javadesktop.org wrote:

> Thanks Brian,
> This fix has solved all my problems (at least with imageio)
>
> Benoit
>
> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org wrote:
>
>> Got it.
>>
>> Thanks ...
>>
>> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org
>> wrote:
>>
>>> Thanks Brian.
>>> I created a new issue and attached a similar file,
>> generating the same exception.
>>>
>>> Benoit
>>>
>>>> And the entire image is in one strip.
>>>>
>>>> Would you please file an issue here
>>>>
>>>>
>> https://jai-imageio-core.dev.java.net/issues/enter_bug
>>>> .cgi?issue_type=DEFECT
>>>>
>>>> and include the image as an attachment (unless it
>> is
>>>> confidential).
>>>>
>>>> Thanks ...
>>>>
>>>> On Thu, 30 Aug 2007, jai-imageio@javadesktop.org
>>>> wrote:
>>>>
>>>>> Yes, the file is compressed using CCITT T.4.
>>>>> Here are the complete metadata for the first page
>>>> (but same compression for page 2)
>>>>> NewSubfileType (254) : Default
>>>>> ImageWidth (256) : 1728
>>>>> ImageLength (257) : 1156
>>>>> BitsPerSample (258) : 1
>>>>> Compression (259) : CCITT T.4
>>>>> PhotometricInterpretation (262) : WhiteIsZero
>>>>> FillOrder (266) : RightToLeft
>>>>> StripOffsets (273) : 8
>>>>> SamplesPerPixel (277) : 1
>>>>> RowsPerStrip (278) : 1156
>>>>> StripByteCounts (279) : 36183
>>>>> XResolution (282) : 200/1
>>>>> YResolution (283) : 96/1
>>>>> T4Options (292) : EOLByteAligned
>>>>> ResolutionUnit (296) : Inch
>>>>> Software (305) : ImageMan by Data Techniques,
>> Inc.
>>>>
>>>> ----------------
>>>> 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
>>> [Message sent by forum member 'bdelaco' (bdelaco)]
>>>
>>>
>> http://forums.java.net/jive/thread.jspa?messageID=2334
>> 13
>>>
>>>
>> ------------------------------------------------------
>> ---------------
>>> 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
> [Message sent by forum member 'bdelaco' (bdelaco)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233603
>
> ---------------------------------------------------------------------
> 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