How can I decode LZW in Java?

I have a database that contains image data stored as a binary blob. The documentation says that the data is encoded using LZW. I thought that I could decode it using the Zip or GZip input streams found in the Java library, but this did not work - I have an exception which states that the data format is incorrect.

From what I read, the library uses DEFLATE, which is not LZW. In addition, I read about some licensing issues for using the LZW algorithm.

What can I use to decode data? Is there a library? Should I implement it myself? What about licensing issues?

+6
java decoding lzw
source share
4 answers

Here are some links:

And there are others.

Indeed, if the images are LZW compressed TIFF files, the Java Advanced Imaging API seems to support decoding directly (although not encoding it seems).

+1
source share

I know the question is old, but I just wanted to add a great resource about LZW:

http://www.matthewflickinger.com/lab/whatsinagif/lzw_image_data.asp

More about using LZW in GIF images, but it describes compression and decompression algorithms very well.

+2
source share

You can also try with 7-Zip JBinding , which uses the 7zip internal library. It is pretty easy to use.

+1
source share

I looked through an amazing amount of LZW implementations before finding the one that worked for my case.

The UncompressedInputStream from the BioJava project worked for me when I needed to unzip the .pax file.

+1
source share

All Articles