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

Support for TIFF with LZW with more than 12 bits per code #84

Closed
michal-niklas opened this issue Dec 2, 2014 · 5 comments
Closed

Support for TIFF with LZW with more than 12 bits per code #84

michal-niklas opened this issue Dec 2, 2014 · 5 comments
Milestone

Comments

@michal-niklas
Copy link

Hello,

One of TIFF images I tried to open with your plugin failed with exception:

com.twelvemonkeys.io.enc.DecodeException: TIFF LZW with more than 12 bits per code encountered (table overflow)
at com.twelvemonkeys.imageio.plugins.tiff.LZWDecoder.addStringToTable(Unknown Source)
at com.twelvemonkeys.imageio.plugins.tiff.LZWDecoder.decode(Unknown Source)
at com.twelvemonkeys.io.enc.DecoderStream.fill(Unknown Source)
at com.twelvemonkeys.io.enc.DecoderStream.read(Unknown Source)
at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385)
at com.twelvemonkeys.imageio.plugins.tiff.HorizontalDeDifferencingStream.fetch(Unknown Source)
at com.twelvemonkeys.imageio.plugins.tiff.HorizontalDeDifferencingStream.read(Unknown Source)
at java.io.DataInputStream.readFully(DataInputStream.java:195)
...

This TIFF opens without problems with GIMP, Krusader preview or with Pythons PIL library. It seems to be grayscale, 8 bits per pixel, LZW compression.

@haraldk
Copy link
Owner

haraldk commented Dec 2, 2014

Hi Michal,

Thanks for reporting!

Strange. More than 12 bits per code, usually means an error in the encoder or decoder, as this would normally lead to an unreasonably large dictionary, and can easily be avoided by resetting the dictionary... But.. Could be my decoder. ;-)

Can you send me the file in question? Either as a link (dropbox or similar), or as an attachment in an email. If you do that, I'll have a look at it! :-)

Regards,

Harald K

@haraldk haraldk added this to the 3.1 milestone Dec 3, 2014
@haraldk
Copy link
Owner

haraldk commented Dec 3, 2014

Hi,

Thanks for providing a sample. I can reproduce the problem.

I can also read it fine, if I enable the "compatibility" mode of the LZW-decoder, there's just no way to do that other than changing the code at the moment...

If you're in a hurry, you can try changing LZWDecoder.java (around line 196):

    protected LZWSpecDecoder() {
        super(true); // Used to be false, set to true to use compatibility mode
    }

In any case, I'll look into it, and hope to have a fix available soon.

Best regards,

Harald K

@haraldk
Copy link
Owner

haraldk commented Dec 4, 2014

Fixed in 27b2ff3.

Harald K

@haraldk haraldk closed this as completed Dec 4, 2014
@michal-niklas
Copy link
Author

I have just compiled it and it works. Thank you!

@haraldk
Copy link
Owner

haraldk commented Jan 3, 2015

FYI: This fix is included in the 3.0.2 release, and will be on Maven Central in a few hours. :-)

Harald K

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