Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected End of PackBits Stream for some TIFF files #489

Closed
annacc-everlaw opened this issue Jul 10, 2019 · 7 comments
Closed

Unexpected End of PackBits Stream for some TIFF files #489

annacc-everlaw opened this issue Jul 10, 2019 · 7 comments
Assignees

Comments

@annacc-everlaw
Copy link

Hiya. For some TIFF files that I've attempted to read using your library, I run into the following exception:

java.io.EOFException: Unexpected end of PackBits stream
	at com.twelvemonkeys.io.enc.PackBitsDecoder.readFully(PackBitsDecoder.java:202)
	at com.twelvemonkeys.io.enc.PackBitsDecoder.decode(PackBitsDecoder.java:158)
	at com.twelvemonkeys.io.enc.DecoderStream.fill(DecoderStream.java:180)
	at com.twelvemonkeys.io.enc.DecoderStream.read(DecoderStream.java:124)
	at com.twelvemonkeys.io.LittleEndianDataInputStream.readFully(LittleEndianDataInputStream.java:425)
	at com.twelvemonkeys.io.LittleEndianDataInputStream.readFully(LittleEndianDataInputStream.java:398)
	at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.readStripTileData(TIFFImageReader.java:1863)
	at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1102)
	at javax.imageio.ImageReader.read(ImageReader.java:939)

I've attached one of the files that caused this error in the following ZIP, because for whatever reason GitHub won't allow me to attach the TIFF directly:

TIFF Error.tif.zip

If you need any extra information from me, I am happy to provide it.

Thanks!

@haraldk
Copy link
Owner

haraldk commented Jul 10, 2019

Thanks for reporting!

I’ll look into it as soon as I’m back in the office. 😀

Best regards,

--
Harald K

@annacc-everlaw
Copy link
Author

@haraldk Hey! Sorry to bother, just wondering what the status of this is?

Thanks!

@haraldk
Copy link
Owner

haraldk commented Aug 6, 2019

Hi,

No worries. I just came back to work yesterday, and will look at the issue some time this week. Hopefully today.

--
Harald K

@haraldk haraldk self-assigned this Aug 6, 2019
@haraldk
Copy link
Owner

haraldk commented Aug 6, 2019

Okay,

Had a quick look and it seems the problem is a combination of the software ("IMAGE MAKER: Spittin' Image Software Inc. V1.0") writing the TIFF not ending the PackBits stream correctly or not writing the correct StripByteCounts value, and my PackBits decoder trying to be a little too smart by reading ahead to decode faster.

I can probably fix this in my PackBits decoder, so that it no longer does this read-ahead.

--
Harald K

@annacc-everlaw
Copy link
Author

Yeah, I'm not super well versed in the TIFF format, but I guessed that it had something to do with the ancient software that made it.

Thank you for looking into it! Very helpful.

@haraldk
Copy link
Owner

haraldk commented Aug 7, 2019

I pushed a fix for this issue now.

--
Harald K

@annacc-everlaw
Copy link
Author

Amazing! Thank you so much!

haraldk added a commit that referenced this issue Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants